TransWikia.com

Synctex and Environments

TeX - LaTeX Asked by Meneldur on December 5, 2020

Synctex makes it possible to jump between your LaTeX code and the compiled PDF, which is absolutely great, if you have larger documents. However it is my impression that when you use environments, Synctex jumps only to the environment rather than the precise location you want to jump. This does not matter, if your environments are small, but it is very annoying, if your environments are large. Is there any way around this problem, e.g. changing the implementation of the environment or reconfiguring synctex etc.?

This questions is a result of discussion Comment Multi-line Text on Counter Condition, because the result of this dicussion is an environment that typically includes large quantities of text.

This question might be similar to SyncTeX functionality in TeXShop and TeXworks, but I am not specifically interested in TeXShop.

One Answer

I had a similar question here: Is there a change to get SyncTeX work with text within environments?

The thing is that Environ has the problem that within an environment generated by NewEnviron the BODY will only recognized as one block by SyncTeX.

But in environments created with newenvironment the text within the environment is recognized by SyncTeX. Nevertheless, as also stated in SyncTeX functionality in TeXShop and TeXworks, SyncTeX recognizes only lines. So you have to use line breaks in you editor to get an appropriate resolution with SyncTeX.

If we takt the example from Comment Multi-line Text on Counter Condition, we get the folowing:

documentclass{scrartcl}
usepackage{environ}

usepackage{ifthen}
usepackage{comment}
usepackage{verbatim}

newcounter{rlpublvl}%   %this counter stores the publication level
newcommand{rlstetpublvl}[1]{setcounter{rlpublvl}{#1}}%    %sets the publication level to #1

newenvironment{rltext}{}{}%
  
newcommand{rlcheckstatus}[1]{%    %activates the environment rltext if #1 >= rlpublvl
    addtocounter{rlpublvl}{-1}%
    ifthenelse{#1 > value{rlpublvl}}%
        {includecomment{rltext}}%
        {excludecomment{rltext}} %
    addtocounter{rlpublvl}{1}%
}%

newififhide
hidefalse
newenvironment{rlctxt}[1]{%
    addtocounter{rlpublvl}{-1}%
    ifthenelse{#1 > value{rlpublvl}}%
        {}%
        {hidetrueexpandaftercomment} %
}%
{%
ifhide
   endcommenthidefalse
fi
addtocounter{rlpublvl}{1}%
}%


begin{document}

rlstetpublvl{5}    %global publication level set to 5

rlcheckstatus{5} %this is printed
begin{rltext}
This is ready
for publication.
end{rltext}

rlcheckstatus{0}  %this is not printed
begin{rltext}
This part is still under construction.
end{rltext}

%-------

begin{rlctxt}{5}%  %this is printed
This is ready
for publication.
end{rlctxt}

begin{rlctxt}{0}%  %this is not printed
This part is still under construction.
end{rlctxt}
end{document}

Now rlctxt works with SyncTex as expected line-by-line with the text within the environment. rltext does not work like this because text in environments from the comment package are again recognized as one block by SyncTeX.

Answered by marli on December 5, 2020

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