Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight changes in text overlayed onto figure (inkscape pdf-tex export) #280

Open
hernot opened this issue Apr 26, 2023 · 1 comment
Open

Comments

@hernot
Copy link

hernot commented Apr 26, 2023

I do have a figure which consists of a tex file which uses picture environment to overlay pdf picture with text typeset by latex.
Some of the label textshave changed. In order to indicate which texts have changed i i want to use the same highlighting for these labels as for regular text or in caption.

How can i tell latex diff to not just frame the figure but highlight the changed labels one by one showing which was changed and if really fancy how.

Attached the original file (inside test/) including pdf and pdf_tex and the
pdf_tex.zip

As i have a large nested document i run these in shell using

# packages is parsed from preamble document using sed script
# for simplicity included here as expanded string
packages="fontenc,inputenc,calc,indentfirst,fancyhdr,graphicx,show:fontenc,inputenc,calc,indentfirst,fancyhdr,graphicx,epstopdf,lastpage,ifthen,lineno,float,amsmath,setspace,enumitem,mathpazo,booktabs,titlesec,etoolbox,tabto,xcolor,soul,multirow,microtype,tikz,totcount,changepage,attrib,upgreek,cleveref,amsthm,hyphenat,natbib,hyperref,footmisc,url,geometry,newfloat,caption,moresize,graphicx,subfigure,calc,units,bm"
for f in *.tex images/*.pdf_tex tables/*.tex ;do 
    latexdiff --packages="$packages" --type=CCHANGEBAR --append-context2cmd="abstract,picture" --driver=pdftex test/$f $f > diff/$f
done

Alternatively which lines in the source should i check to make this work if currently not possible yet (*).

(*) its years and years since last touching perl so would prefer if achievable without

@hernot
Copy link
Author

hernot commented Apr 27, 2023

ho do i tell latexdiff to not just put \DIFdelbegin, \DIFdelend, \DIFaddbegin and DIFaddend tokens when removing picture form PICTUREENV variable but also enclose changed text within \DIFdel DIFadd commands which do the actual coloring

EDIT 1

Adding ---append-safecmd to enable put makebox smash commands and -config to make latexdiff to report individual changes inside picture is half of the trick. For the rest i do fear i will have for now to do my own preamble redefining \put and disable \color command when inside DIFadd wrapped \put command

# for simplicity included here as expanded string
packages="fontenc,inputenc,calc,indentfirst,fancyhdr,graphicx,show:fontenc,inputenc,calc,indentfirst,fancyhdr,graphicx,epstopdf,lastpage,ifthen,lineno,float,amsmath,setspace,enumitem,mathpazo,booktabs,titlesec,etoolbox,tabto,xcolor,soul,multirow,microtype,tikz,totcount,changepage,attrib,upgreek,cleveref,amsthm,hyphenat,natbib,hyperref,footmisc,url,geometry,newfloat,caption,moresize,graphicx,subfigure,calc,units,bm"
for f in *.tex images/*.pdf_tex tables/*.tex ;do 
    latexdiff --packages="$packages" --type=CCHANGEBAR --append-context2cmd="abstract" --driver=pdftex --append-safecmd="makebox,put,smash" --config="PICTUREENV=tikzpicture[\w\d*@]*;DIFnomarkup;" test/$f $f > diff/$f
done

EDIT 2
Ok figured the second part too. It worked with a small filter (*) and a custom preamble which are both attached. Tried to keep it as clean and least hacky as possible. The call looks now as follows

# for simplicity included here as expanded string
packages="fontenc,inputenc,calc,indentfirst,fancyhdr,graphicx,show:fontenc,inputenc,calc,indentfirst,fancyhdr,graphicx,epstopdf,lastpage,ifthen,lineno,float,amsmath,setspace,enumitem,mathpazo,booktabs,titlesec,etoolbox,tabto,xcolor,soul,multirow,microtype,tikz,totcount,changepage,attrib,upgreek,cleveref,amsthm,hyphenat,natbib,hyperref,footmisc,url,geometry,newfloat,caption,moresize,graphicx,subfigure,calc,units,bm"
for f in *.tex images/*.pdf_tex tables/*.tex ;do 
    # NOTE: the '--append-safecms="makebox,put,smash" would not be necessary' as latexdiff does mark the
    # whole '\put' sequence mark as changed and not just the content of '\makebox'  anyway 
    latexdiff --packages="$packages" --type=CCHANGEBAR --append-context2cmd="abstract" --driver=pdftex --append-safecmd="makebox,put,smash" --config="PICTUREENV=tikzpicture[\w\d*@]*;DIFnomarkup;" test/$f $f > diff/$f
done

latexdif_filter_pls_preamble.zip

The filter is thee simple substitute command replacing picture environment by its DIF pendents and \color command by \DIFcolor on all files. And the rest is handled by preamble.

And the result looks like this:

image

(*) Filter is in unix shell plus sed as my perl knowledge is from last century, did not seriously practice perl since shortly after start of this century.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant