diff --git a/build.sh b/build.sh index 54a5501..698283b 100755 --- a/build.sh +++ b/build.sh @@ -500,6 +500,11 @@ do_tex_fixups() { # prefix these lines with + and - sed -i.bak 's/^%DIF < /%DIF <- /g' "${input}" sed -i.bak 's/^%DIF > /%DIF >+ /g' "${input}" + + # latexdiff' \DIFaddbegin absorbs a space before it. + # This is fairly common (e.g., in the case of an added sentence) + # Preserve them by inserting a space after. + sed -i.bak 's/ \\DIFaddbegin/ \\DIFaddbegin ~/g' "${input}" } if test "${DO_GITVERSION}" == "yes"; then diff --git a/template/latexdiff.tex b/template/latexdiff.tex index d7fb225..3f06f94 100644 --- a/template/latexdiff.tex +++ b/template/latexdiff.tex @@ -1,4 +1,4 @@ -% Custom preamble based on --type=pdfcomment --driver xetex +% Custom preamble based on --type=pdfmargincomment --driver xetex % Mark up added text with a blue underline, and removed text with a red strikethrough. % Choose blue/red instead of green/red for accessibility (red-green colorblindness modes constitute the most common forms). @@ -10,13 +10,13 @@ % https://tex.stackexchange.com/questions/474947/highlighting-text-that-spans-multiple-lines-with-pdfmarkupcomment-from-pdfcomme % \providecommand{\DIFadd}[1]{\pdfmarkupcomment[author=Inserted,markup=Underline,color=blue]{#1}{#1}} % \providecommand{\DIFdel}[1]{\pdfmarkupcomment[author=Deleted,markup=StrikeOut,color=red]{#1}{#1}} -% hspaces are here to ensure that on all PDF readers, the comment indicator does not cover up the text. \providecommand{\DIFadd}[1]{{\color{blue} \uline{#1}}} \providecommand{\DIFdel}[1]{{\color{red} \sout{#1}}} % Basic add/del/mod environments. -\providecommand{\DIFaddbegin}{\pdfcomment[author=Inserted,icon=Note,color=blue]{Text} \hspace{16pt}} +% \providecommand{\DIFaddbegin}{\pdfmargincomment[author=Inserted,icon=Note,color=blue]{Text}} +\providecommand{\DIFaddbegin}{\pdfmargincomment[author=DIFF,icon=Note,color=tcg-template-neon-green]{Inserted text}} \providecommand{\DIFaddend}{} -\providecommand{\DIFdelbegin}{\pdfcomment[author=Deleted,icon=Note,color=red]{Text} \hspace{16pt}} +\providecommand{\DIFdelbegin}{\pdfmargincomment[author=DIFF,icon=Note,color=tcg-template-neon-green]{Removed text}} \providecommand{\DIFdelend}{} \providecommand{\DIFmodbegin}{} \providecommand{\DIFmodend}{} @@ -24,9 +24,9 @@ % For floats, we use the graphics macros below. \providecommand{\DIFaddFL}[1]{#1} \providecommand{\DIFdelFL}[1]{#1} -\providecommand{\DIFaddbeginFL}{\pdfcomment[author=Inserted,icon=Note,color=blue]{Image}} +\providecommand{\DIFaddbeginFL}{\pdfmargincomment[author=DIFF,icon=Note,color=tcg-template-neon-green]{Inserted image}} \providecommand{\DIFaddendFL}{} -\providecommand{\DIFdelbeginFL}{\pdfcomment[author=Deleted,icon=Note,color=red]{Image}} +\providecommand{\DIFdelbeginFL}{\pdfmargincomment[author=DIFF,icon=Note,color=tcg-template-neon-green]{Removed image}} \providecommand{\DIFdelendFL}{} % % Latexdiff by default wants to shrink deleted figures. Let's try not doing that, @@ -97,11 +97,11 @@ keepspaces=true } \lstnewenvironment{DIFverbatim}{ - \pdfcomment[author=Changed,color=blue,icon=Note]{- Deleted, + Inserted} + \pdfmargincomment[author=DIFF,color=tcg-template-neon-green,icon=Note]{- Deleted, + Inserted} \lstset{style=DIFverbatimstyle} }{} \lstnewenvironment{DIFverbatim*}{ - \pdfcomment[author=Changed,color=blue,icon=Note]{- Deleted, + Inserted} + \pdfmargincomment[author=DIFF,color=tcg-template-neon-green,icon=Note]{- Deleted, + Inserted} \lstset{style=DIFverbatimstyle,showspaces=true} }{} \lstset{extendedchars=\true,inputencoding=utf8} diff --git a/template/tcg.tex b/template/tcg.tex index 6eda17b..dbd7147 100644 --- a/template/tcg.tex +++ b/template/tcg.tex @@ -132,7 +132,9 @@ \urlstyle{same} % disable monospaced font for URLs -\usepackage[top=0.5in,left=0.5in,right=0.5in,bottom=0.8in,$for(geometry)$$geometry$$sep$,$endfor$]{geometry} +% An explicit marginparwidth allows pdfmargincomment to place the icon in the right margin (for diffs). +% 0in is fine because we don't put actual contents into the margin. +\usepackage[top=0.5in,left=0.5in,right=0.5in,marginparwidth=0in,bottom=0.8in,$for(geometry)$$geometry$$sep$,$endfor$]{geometry} \setlength{\paperheight}{11in} \setlength{\paperwidth}{8.5in} @@ -288,6 +290,8 @@ % Define some colors that we'll use from style-fenced-divs.lua and informative-quote-blocks.lua. % +\definecolor{tcg-template-neon-green}{RGB}{153, 196, 84} + % Informative text color, also used for notes and examples. \definecolor{informative-background}{RGB}{224, 224, 224} \definecolor{informative-header}{RGB}{10, 10, 10}