4

This question already has an answer here:

I'm trying to inline a few snippets of diff patches, and manually formatting them is a droll - is there a way to do it automatically?

In general I want it to look like the following example, but obviously the finer details of font and colour are less important (as long as they're internally consistent)

Diff patch example

marked as duplicate by egreg, Peter Jansson, ChrisS, Werner, Speravir Feb 6 '14 at 21:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • By automatic formatting, are you referring to the colour, the layout, or something else altogether? – Werner Feb 6 '14 at 20:11
  • Colours, mostly - but also that it be in monospace font, a self contained block, etc. – Daniel Feb 6 '14 at 20:12
5

This may be a start - using `fancyvrb:

enter image description here

\documentclass{article}
\usepackage{fancyvrb,xcolor}% http://ctan.org/pkg/{fancyvrb,xcolor}
%\newcommand{\defaultformat}{\color{black}}
\newcommand{\typeA}{\color{green!50!black}}
\newcommand{\typeB}{\color{red!60!black}}
\newcommand{\typeC}{\color{blue!70!yellow}}
\newcommand{\typeD}{\color{green!60!blue}}
\begin{document}

\begin{Verbatim}[commandchars=\~\{\}]
~typeA--- <unnamed>
~typeA+++ <unnamed>
~typeB@@ -47,13 +47,14 @@

 ;; t \in Term
 ;; t ::= '(true) | '(false) | '(z) | `(if-then-else ,t ,t ,t)
~typeC-;;     | `(succ ,t) | `(pred ,t) | `(zero? ,t)
~typeD+;;     | `(succ ,t) | `(pred ,t) | `(zero? ,t) | `(pr ,t ,t)
~typeD+;;     | `(first ,t) | `(second ,t)

 ;; nv \in Num
\end{Verbatim}

\end{document}

Not the answer you're looking for? Browse other questions tagged or ask your own question.