1

I want to create a "diff" effect using the pseudo package, inspired by GitHub/Gerrit diffs. However, the symbols at the start of the line aren't lined up - they move when the digits go from 9 to 10. How can I get this to look nice? Can I force the numbers to be fixed-width, or set a tabular prelude that gives me a column for the "+"/"-" symbols?

Example:

enter image description here

\documentclass{article}
\usepackage{xcolor}
\usepackage{pseudo}
\pseudodefinestyle{rm}{bol-prepend=\rowcolor{red!30!white}{--}\quad}
\pseudodefinestyle{gp}{bol-prepend=\rowcolor{green!30!white}+\quad}

\begin{document} \begin{pseudo}[start=7] foo \[rm] bar \[gp] baz \[gp] quuz \[gp] snoz \ blep \end{pseudo} \end{document}

1 Answers1

1

Using the prefix and preamble options you can add a column separator before the numbers:

\documentclass{article}
\usepackage{pseudo}
\pseudodefinestyle{rm}{bol-prepend=\rowcolor{red}{--}}
\pseudodefinestyle{gp}{bol-prepend=\rowcolor{green}+}

\begin{document} \begin{pseudo}[ start=7, prefix={\pseudobol & \stepcounter* \pseudolabel &}, preamble={ >{ \pseudohpad } c >{ \pseudohpad } \pseudolabelalign >{ \pseudosetup } l <{ \pseudohpad } }, ] foo \[rm] bar \[gp] baz \[gp] quuz \+[gp] snoz \- blep \end{pseudo} \end{document}

  • I started writing this post because I was stumped, but then before posting it I found out what the solution was, so I thought I'd share both! – Paul Crowley Oct 06 '23 at 14:19