0

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}

henry
  • 6,594
  • the usage here seems odd as you have defined len and lde as real environments (with definitions that assume they form a group) so you should not use \includecomment simply don't use \excludecomment for len and 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
  • as said in the other question, comment writes the content to an external file comment.cut and reincludes it. So from the view of synctex the source for all environments using \includecomment is this one comment.cut file. Why do you use \includecomment at all? – Ulrike Fischer May 06 '21 at 09:14
  • Sorry to you both. The MWE wasn't complete, hence arguably not quite easy to grasp how I plan to set up a multi-lingual document. @DavidCarlisle I changed the environments ... if I try to incorporate the fake comment-environment into a real language-environment, the commenting-mechanism already works and it produces a runaway error. I would prefer to use a macro for this and not create 2 environments on top of each other (see edited post & MWE above in a few minutes). – henry May 06 '21 at 19:37
  • after the edit you have \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:41
  • what you are setting up seems massively complicated for the relatively common requirement of maintaining a two-language document, but it's hard to tell if you have other requirements that are forcing this complication. – David Carlisle May 06 '21 at 19:44
  • @DavidCarlisle Ok. Well, I simply followed this lead... and enhanced it for getting babel and selecting the relevant language for that part. – henry May 06 '21 at 19:54
  • @henry: as a matter of implementation, if you switch to the xcomment package instead, you can save one level of nesting. (Just use your existing langde and langen environments and put everything inside a huge xcomment that selects from the two.) – Willie Wong May 06 '21 at 20:30

0 Answers0