Skip to content

Commit d3e8ed1

Browse files
committed
re-style icons and move them to the margins in diffs
1 parent 9cdcb08 commit d3e8ed1

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,11 @@ do_tex_fixups() {
500500
# prefix these lines with + and -
501501
sed -i.bak 's/^%DIF < /%DIF <- /g' "${input}"
502502
sed -i.bak 's/^%DIF > /%DIF >+ /g' "${input}"
503+
504+
# latexdiff' \DIFaddbegin absorbs a space before it.
505+
# This is fairly common (e.g., in the case of an added sentence)
506+
# Preserve them by inserting a space after.
507+
sed -i.bak 's/ \\DIFaddbegin/ \\DIFaddbegin ~/g' "${input}"
503508
}
504509

505510
if test "${DO_GITVERSION}" == "yes"; then

template/latexdiff.tex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
% Custom preamble based on --type=pdfcomment --driver xetex
1+
% Custom preamble based on --type=pdfmargincomment --driver xetex
22

33
% Mark up added text with a blue underline, and removed text with a red strikethrough.
44
% Choose blue/red instead of green/red for accessibility (red-green colorblindness modes constitute the most common forms).
@@ -10,23 +10,23 @@
1010
% https://tex.stackexchange.com/questions/474947/highlighting-text-that-spans-multiple-lines-with-pdfmarkupcomment-from-pdfcomme
1111
% \providecommand{\DIFadd}[1]{\pdfmarkupcomment[author=Inserted,markup=Underline,color=blue]{#1}{#1}}
1212
% \providecommand{\DIFdel}[1]{\pdfmarkupcomment[author=Deleted,markup=StrikeOut,color=red]{#1}{#1}}
13-
% hspaces are here to ensure that on all PDF readers, the comment indicator does not cover up the text.
1413
\providecommand{\DIFadd}[1]{{\color{blue} \uline{#1}}}
1514
\providecommand{\DIFdel}[1]{{\color{red} \sout{#1}}}
1615
% Basic add/del/mod environments.
17-
\providecommand{\DIFaddbegin}{\pdfcomment[author=Inserted,icon=Note,color=blue]{Text} \hspace{16pt}}
16+
% \providecommand{\DIFaddbegin}{\pdfmargincomment[author=Inserted,icon=Note,color=blue]{Text}}
17+
\providecommand{\DIFaddbegin}{\pdfmargincomment[author=DIFF,icon=Note,color=tcg-template-neon-green]{Inserted text}}
1818
\providecommand{\DIFaddend}{}
19-
\providecommand{\DIFdelbegin}{\pdfcomment[author=Deleted,icon=Note,color=red]{Text} \hspace{16pt}}
19+
\providecommand{\DIFdelbegin}{\pdfmargincomment[author=DIFF,icon=Note,color=tcg-template-neon-green]{Removed text}}
2020
\providecommand{\DIFdelend}{}
2121
\providecommand{\DIFmodbegin}{}
2222
\providecommand{\DIFmodend}{}
2323

2424
% For floats, we use the graphics macros below.
2525
\providecommand{\DIFaddFL}[1]{#1}
2626
\providecommand{\DIFdelFL}[1]{#1}
27-
\providecommand{\DIFaddbeginFL}{\pdfcomment[author=Inserted,icon=Note,color=blue]{Image}}
27+
\providecommand{\DIFaddbeginFL}{\pdfmargincomment[author=DIFF,icon=Note,color=tcg-template-neon-green]{Inserted image}}
2828
\providecommand{\DIFaddendFL}{}
29-
\providecommand{\DIFdelbeginFL}{\pdfcomment[author=Deleted,icon=Note,color=red]{Image}}
29+
\providecommand{\DIFdelbeginFL}{\pdfmargincomment[author=DIFF,icon=Note,color=tcg-template-neon-green]{Removed image}}
3030
\providecommand{\DIFdelendFL}{}
3131

3232
% % Latexdiff by default wants to shrink deleted figures. Let's try not doing that,
@@ -97,11 +97,11 @@
9797
keepspaces=true
9898
}
9999
\lstnewenvironment{DIFverbatim}{
100-
\pdfcomment[author=Changed,color=blue,icon=Note]{- Deleted, + Inserted}
100+
\pdfmargincomment[author=DIFF,color=tcg-template-neon-green,icon=Note]{- Deleted, + Inserted}
101101
\lstset{style=DIFverbatimstyle}
102102
}{}
103103
\lstnewenvironment{DIFverbatim*}{
104-
\pdfcomment[author=Changed,color=blue,icon=Note]{- Deleted, + Inserted}
104+
\pdfmargincomment[author=DIFF,color=tcg-template-neon-green,icon=Note]{- Deleted, + Inserted}
105105
\lstset{style=DIFverbatimstyle,showspaces=true}
106106
}{}
107107
\lstset{extendedchars=\true,inputencoding=utf8}

template/tcg.tex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@
132132

133133
\urlstyle{same} % disable monospaced font for URLs
134134

135-
\usepackage[top=0.5in,left=0.5in,right=0.5in,bottom=0.8in,$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
135+
% An explicit marginparwidth allows pdfmargincomment to place the icon in the right margin (for diffs).
136+
% 0in is fine because we don't put actual contents into the margin.
137+
\usepackage[top=0.5in,left=0.5in,right=0.5in,marginparwidth=0in,bottom=0.8in,$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
136138

137139
\setlength{\paperheight}{11in}
138140
\setlength{\paperwidth}{8.5in}
@@ -288,6 +290,8 @@
288290
% Define some colors that we'll use from style-fenced-divs.lua and informative-quote-blocks.lua.
289291
%
290292

293+
\definecolor{tcg-template-neon-green}{RGB}{153, 196, 84}
294+
291295
% Informative text color, also used for notes and examples.
292296
\definecolor{informative-background}{RGB}{224, 224, 224}
293297
\definecolor{informative-header}{RGB}{10, 10, 10}

0 commit comments

Comments
 (0)