tags:

views:

791

answers:

2

Hi

I have a little problem where I would like to insert a svn diff of a LaTeX document into another LaTeX document, the goal is to show what has changed since revision XXX. However since the diff contains a lot of LaTeX command I can't include it right into the document since LaTeX will interpit them and not just "print" them.

Today I have this in my Makefile

DIFF_INFO=diff.info.tex
DIFF_REV=167
diffinfo:
    $(shell echo "\n" > $(DIFF_INFO) )
    $(shell echo "\\section{diff $(DIFF_REV)} \n" >> $(DIFF_INFO) )
    $(shell echo \\\\begin{verbatim} >> $(DIFF_INFO) )
    $(shell svn diff --revision $(DIFF_REV) $(N).tex >> $(DIFF_INFO) )
    $(shell echo \\\\end{verbatim} >> $(DIFF_INFO) )

And at the end of the LaTeX document I have this:

\IfFileExists{diff.info.tex}
{
  \newpage
  \input{diff.info.tex}
}

But this fails hard!

My next idea is to write a perl script that replaces all invalid chars with something that LaTeX can show, but it feels like I'm risking to reinvent the wheel so I figured that I could ask if someone had a better idea?

How do I include and show LaTeX code in the document?

Thanks Johan


Update: Thanks "unknown (google)" for pointing out verbatim, it did what I wanted it to.

Update: I also looks like I should try that listings that las3rjock told us about since it look kind of nice.

Update: Could not get listings to work in my case, I get some strange utf warnings about invalid chars. But the verbatim is working so I will use that way this time.

+5  A: 

There' a verbatim package that you can include with \usepackage{verbatim} and access using \verbatiminput{filename}.

Agreed. I was going to recommend the listings package which offers the same thing in the \lstinputlisting{filename} command. Particularly for programmatically generated files like a diff, this is the way the way to go since it keeps the containing TeX file as a nice, clean template.
Boojum
Yeah - lstinputlisting is almost always better than verbatiminput. I avoid verbatim in almost all occasions.
Eamon Nerbonne
+8  A: 
las3rjock