# Synctex and Environments

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.

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
\ifthenelse{#1 > \value{rlpublvl}}%
{\includecomment{rltext}}%
{\excludecomment{rltext}} %
}%

\newif\ifhide
\hidefalse
\newenvironment{rlctxt}[1]{%
\ifthenelse{#1 > \value{rlpublvl}}%
{}%
{\hidetrue\expandafter\comment} %
}%
{%
\ifhide
\endcomment\hidefalse
\fi
}%

\begin{document}

\rlstetpublvl{5}    %global publication level set to 5

\rlcheckstatus{5} %this is printed
\begin{rltext}
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

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.