Skip to content

Commit

Permalink
re-style icons and move them to the margins in diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfenner committed Oct 6, 2024
1 parent 9cdcb08 commit d3e8ed1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions template/latexdiff.tex
Original file line number Diff line number Diff line change
@@ -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).
Expand All @@ -10,23 +10,23 @@
% 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}{}

% 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,
Expand Down Expand Up @@ -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}
Expand Down
6 changes: 5 additions & 1 deletion template/tcg.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit d3e8ed1

Please sign in to comment.