In latexdiff
, the default is to protect citation commands with an \mbox
so that they are printed properly in the default style. How can I add other commands to be protected by an \mbox
, such as \SI{}{}
or \cref{}
?
new.tex
% arara: pdflatexmk
\documentclass{article}
\usepackage{siunitx}
\begin{document}
This is the new text \SI{300}{\meter\per\second}
\end{document}
old.tex
% arara: pdflatexmk
\documentclass{article}
\usepackage{siunitx}
\begin{document}
This is the old text \SI{600}{\meter\per\second}
\end{document}
Output of latexdiff --append-safecmd="SI"
(compiling fails, but adding an \mbox
around the siunitx
commands succeeds):
% arara: pdflatexmk
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL test_old.tex Sun Dec 21 11:40:33 2014
%DIF ADD test.tex Sun Dec 21 11:40:38 2014
\documentclass{article}
\usepackage{siunitx}
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF
\begin{document}
This is the \DIFdelbegin \DIFdel{old text \SI{600}{\meter\per\second}
}\DIFdelend \DIFaddbegin \DIFadd{new text \SI{300}{\meter\per\second}
}\DIFaddend\end{document}
Best Answer
Other commands are treated equivalently to the citation commands if defined in the following option:
--append-mboxsafecmd="cmd1,cmd2,..."
(requires latexdiff version 1.1.0 or higher). If the siunitx package is detected, this is done automatically for
\SI
.