Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Short question

Seems like --flatten doesn't work properly with latexdiff-vc. How can I get this working, without reverting to my elaborated workflow described below?

Context

I track the history of my Latex documents using SVN. I've recently started using latexdiff to generate PDFs highlighting the changes between certain revisions.

My initial workflow of svn+latexdiff was (1) to copy over the whole svn folder to a temporary lcoation, (2) update this to the relevant revision, (3) go back to the original svn folder and (4) start latexdiff specifying the relevant folders and files. As I split up my latex document in multiple files using \input{} statements, I have to use the latexdiff --flatten option to get this working. So, at the Windows command prompot I type something like:

latexdiff --flatten ..\..\copy_at_r48\main.tex main.tex > diff.tex

I figured there must be an easier way and bumped into latexdiff-vc which supports specifying svn revisions directly. However, the following doesn't seem to work, as the old versions of linked files doesn't seem to get retrieved/flatten; there are only DIFF markings in the main content:

latexdiff-vc --flatten -r 48 main.tex
share|improve this question
    
I never got latexdiff-vc to work either. My workflow is: 1) flatten the document (using a perl script) 2) checkin that document 3) checkout previously flattened document 4) run latexdiff on working copy of flattened document and checkout version. Not perfect by any means, but relatively simple and quick if you combine all those steps in a batch file –  Jörg Jun 27 '12 at 15:03

1 Answer 1

up vote 4 down vote accepted

I've written a very simple Windows batch script (latexdiff-svn.bat) that automated my described workflow. It exports a given revision of the the svn working copy to a temporary folder (typically under C:\Users\username\AppData\Local\Temp), performs latexdiff --flatten, and deletes the temporary folder.

The actual barebones script is only 5 lines

:: Usage: 
::      latexdiff-svn <svn revision number> <filename>
set tempfolder=%TEMP%\latexdiffsvn
rmdir /s /q %tempfolder%
svn export -r %1 . %tempfolder%
latexdiff --flatten %tempfolder%/%2 %2 > diff-%2-r%1.tex
rmdir /s /q %tempfolder%



And below a slightly more elaborated version that does some basic checking on the parameters, and provides some friendly clues to the user. You can copy-paste the code in a file named for example 'latexdiff-svn.bat'

:: Usage: 
::      latexdiff-svn <svn revision number> <filename>
:: e.g.
::      latexdiff-svn.bat 23 main.tex

::Some basic checks on the arguments
@if "%1"=="" goto not_enough_parameters
@if "%2"=="" goto not_enough_parameters
@if not exist %2 goto file_does_not_exist
@svn info -r %1 > NUL
@if errorlevel 1 goto revision_does_not_exist
@goto all_seems_ok

:not_enough_parameters
@echo.
@echo I need exactly two arguments, the first one specifying 
@echo the svn revision number, the second one the file name.
@echo Example syntax:
@echo    latexdiff-svn 23 main.tex
@goto :EOF

:file_does_not_exist
@echo.
@echo I couldn't find the file you specified: %2
@goto :EOF

:revision_does_not_exist
@echo.
@echo The current folder does not contain an svn working copy, 
@echo or the revision number specified (%1) does not exist
@goto :EOF

:all_seems_ok
@set tempfolder=%TEMP%\latexdiffsvn
@set difffile=diff-%2-r%1.tex
@if exist %tempfolder% rmdir /s /q %tempfolder%
@echo Creating temporary folder at revision %1
@svn export -r %1 . %tempfolder% > NUL
@echo Running latexdiff
latexdiff --flatten %tempfolder%/%2 %2 > %difffile%

:cleanup
@if exist %tempfolder% rmdir /s /q %tempfolder%

@echo.
@echo Written to: %difffile%
@echo Done !

Note: the latexdiff script used with the --flatten option outputs a few DEBUG lines. If you want to suppress these (without fixing the perl script itself), see the solution to this stackoverflow question: http://stackoverflow.com/questions/11362041/how-to-suppress-specific-lines-in-windows-cmd-output

share|improve this answer
    
That's a nice workaround, thank you. Unfortunately, latexdiff's "flatten" option is very limited. For instance, it includes commented "input{x}" commands and only includes top-level inputs (see here). Hence, for my rather complicated documents, I require more advanced "flatten" scripts. –  Jörg Jun 28 '12 at 15:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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