In 2013, there was Synctex Go to source from pdf and comment package.
Now it is 2021 and the problem still exists: for any parts within a comment-environment (in the given example, it is len for English), inverse search does not work, meaning the cursor does not jump to the relevant source code part.
It is arguably easy to reproduce if you compile the MWE below. If you comment out the lines with \begin{len} and \end{len} for one environment-occurrence in the document and compile it again, inverse search works again.
This is actually somewhat disheartening. So far, I have not run into these kinds of big problems with something that much of a problem, imho, for the workflow with LaTeX and my favorite editor in general.
I'd like to make sure: is the usage of comment-environment and the adversarial consequence (for the lack of a better word) of its mechanism towards synctex not been addressed? Or are there known workarounds?
MWE
\documentclass[parskip=full]{scrartcl}
\usepackage{lmodern}
\usepackage{comment}
\usepackage[T1]{fontenc}
%%make the ENGLISH version (main!)
%\includecomment{len}
%\excludecomment{lde}
%---does NOT work, throws a runaway error:
%\newenvironment{langen}{%
%\begin{len}\selectlanguage{english}}
%{\end{len}}
%---does work:
\newenvironment{langen}{%
\selectlanguage{english}}
{}
%%make the German version
\includecomment{lde}
\excludecomment{len}
\begin{lde}
\usepackage[german]{babel}
\end{lde}
\newenvironment{langde}{%
\selectlanguage{german}}
{}
\begin{len}
\usepackage[english]{babel}
\end{len}
\listfiles
\begin{document}
\begin{langen}
\begin{len}
\begin{center}\huge
The Title in English
\end{center}
\end{len}
\end{langen}
\begin{lde}
\begin{langde}
\begin{center}\huge
Titel in deutsch
\end{center}
\end{langde}
\end{lde}
\begin{len}
\begin{langen}
Abc.
Def.
EGJSDFGJ.
DDDDDDDDD.
EEEEEEEEE.
FFFFFFF.
GGGGGG.
\end{langen}
\end{len}
\clearpage
\begin{len}
\begin{langen}
Page 2: some words to form a sentence.
\end{langen}
\end{len}
\begin{lde}
\begin{langde}
Seite 2: Einige deutsche Worte.
\end{langde}
\end{lde}
\end{document}
lenandldeas real environments (with definitions that assume they form a group) so you should not use\includecommentsimply don't use\excludecommentforlenand that environment will act normally. comment package is designed to work with "fake" environments that are not otherwise defined and do not form a group when they are included. – David Carlisle May 05 '21 at 23:38\newenvironment{langen}{% \begin{len}you can not do this, as with all "verbatim" constructs you can not use it inside the argument or definition of another command. – David Carlisle May 06 '21 at 19:41xcommentpackage instead, you can save one level of nesting. (Just use your existinglangdeandlangenenvironments and put everything inside a hugexcommentthat selects from the two.) – Willie Wong May 06 '21 at 20:30