TransWikia.com

Is there a chance to get SyncTeX work with text within environments?

TeX - LaTeX Asked by marli on July 18, 2021

I know that SyncTeX does not work correctly in Beamer (see Inverse PDF Search in beamer).

But there seems to be also a problem with inverse search in environments defined with NewEnviron.

I want to call something like this:

begin{foo}{x}{y}
bla bla
end{foo}

It does not need to be an environment. But I do not know what to use else because I want to control the body which is possible with BODY in NewEnviron but not possible with newenvironment.

So is it possible to define an environment-like thing, where SyncTeX points to the text in the environment and not at the end of the environment?

In itemize-environments it seems to work. Does someone know how it is implemented there?

Example:

documentclass{letter}
usepackage{environ}

newififshow

NewEnviron{foo}[3]{
ifshow
    #1
    BODY
    -----------
else
  Alert #1 #2 #3
fi
}

begin{document}
begin{foo}{hide}{1}{2}
hidden Text
end{foo}

showtrue

begin{foo}{show}{2}{1}
begin{itemize}
    item a
    item b
    item c
end{itemize}
end{foo}

begin{itemize}
    item d
    item e
    item f
end{itemize}

end{document}

For a, b, c inverse search does not work for d, e, f it works. For me it is important that the original text body can be replaced.

One Answer

We can realize it with newenvironment and comment from verbatim:

documentclass{letter}
usepackage{verbatim}

newififshow

newenvironment{foo}[3]{
 ifshow
    #1
 else
    defa{#1}
    defb{#2}
    defc{#3}
    expandaftercomment
 fi
}
{
 ifshow
    -----------
 else
    expandafterendcomment
    Alert a~b~c
 fi
}

begin{document}
begin{foo}{hide}{1}{2}
hidden Text
end{foo}

showtrue

begin{foo}{show}{2}{1}
begin{itemize}
    item a
    item b
    item c
end{itemize}
end{foo}

begin{itemize}
    item d
    item e
    item f
end{itemize}

end{document}

Then inverse search does also work for a, b and c.

Correct answer by marli on July 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP