## Synctex not working with Comment.sty

The official TeXShop Support Forum.

### Synctex not working with Comment.sty

Hello all,

I recently start to use comment.sty (http://www.ctan.org/tex-archive/macros/latex/contrib/comment) that I find extremely useful for producing versions for class notes and exams.

The problem is that clicking on the pdf preview takes me to the correct line of the auxillary document created by comment.sty (file comment.cut) instead of the main document. Editing comment.cut is useless as it is re-created/overwritten from main.tex at each run.

Any help or alternatives to comment.sty will be appreciated !

Best
Last edited by Antoine on Fri Jan 27, 2012 3:56 pm, edited 1 time in total.
Antoine

Posts: 4
Joined: Sun Nov 14, 2010 5:04 pm

### Re: Synctex not working with Comment.sty

Howdy,

Could you create a minimal but compilable example that shows this behavior. I find it very strange that it isn't the final pdf and source file that are in synch.

As an aside: I'm afraid that TeXShop has nothing to do with any strange behavior like this but it has to do with how (xe/pdf)latex produces the .synctex.gz file.

Finally, if the information is in something that appears in a commented out section, i.e., isn't in the final document (pdf), how could a sync possibly work?
Good Luck,
Herb Schulz
Herbert Schulz

Posts: 1489
Joined: Thu May 12, 2005 2:31 pm

### Re: Synctex not working with Comment.sty

hello,

Here is a minimal example. The pdf will show "Only in A'S" but cmd-clicking on it opens the comment.cut document instead of getting back to the main.tex document.

I am using mactex and the latest TeXShop.

Best,

Antoine

Code: Select all
\documentclass{article}% this is main.tex\usepackage{comment}\includecomment{A}\excludecomment{B}\begin{document}This is in all versions\begin{A}Only in A'S\end{A}\begin{B}Only in B'S\end{B}\end{document}
Antoine

Posts: 4
Joined: Sun Nov 14, 2010 5:04 pm

### Re: Synctex not working with Comment.sty

Howdy,

Thanks for the example. It certainly shows the behavior you describe. As I said before I belive this has nothing to do with TeXShop but rather with the way synctex operates. (Un)fortunately I think the behavior may actually be correct!

Imagine that you have a distributed document, i.e., a main file that includes other files as input via either \input or \include commands. If some text appears in one of the included files the proper behavior for synctex (built into (xe/pdf)latex) would be to name that included file so that TeXShop (and other synctex-aware Editors/Previewers) will display the correct text in the correct file.

Well, the comment package works by taking information in an environment created by the \includecomment command (i.e., if you have \includecomment{A} then everything inside

\begin{A}
...
\end{A}

and puts into a comment.cut file and then \input's that file. So, as far as synctex is concerned that material is coming from the comment.cut file and that is the file that has to be displayed.

Interestingly, the next included' comment actually overwrites a previous one and is included so the actual contents pf comment.cut changes with each included comment but as far as synctex is concerned it's at the start of the comment.cut file in all cases.

I would consider this a bug in the comment package but I don't think it's a synctex problem and especially not a TeXShop problem. You might report this behavior to the maintainer of the comment package which is on the CTAN page, <http://www.ctan.org/pkg/comment>. I would expect it would take a drastic re-design of the package for this to work.

I get the list <http://tug.ctan.org/search.html?search=comment&search_type=description> at CTAN when I search for comment' so some of the other packages may offer a feature like the comment package.
Good Luck,
Herb Schulz
Herbert Schulz

Posts: 1489
Joined: Thu May 12, 2005 2:31 pm

### Re: Synctex not working with Comment.sty

Thanks, your remarks are close to what reckoned about the problem. I will contact Victor Eijkhout, the author and cc Jerome Laurens (synctex).

So far I have not found packages that about replicate what comment.sty does, if someone has I would be grateful to know about it.

Cheers !

Antoine
Antoine

Posts: 4
Joined: Sun Nov 14, 2010 5:04 pm

### Re: Synctex not working with Comment.sty

Howdy,

You may also get help with possibly finding a substitute package by asking on the Mac OS X TeX e-mail list. More information about joining is available in the message near the top of this forum.
Good Luck,
Herb Schulz
Herbert Schulz

Posts: 1489
Joined: Thu May 12, 2005 2:31 pm

### Re: Synctex not working with Comment.sty

Thanks, As far as I remember from trying out a few of these (versions.sty comes to mind) was that they had issues with verbatim's inside a comment. Will try again
Antoine

Posts: 4
Joined: Sun Nov 14, 2010 5:04 pm

### Re: Synctex not working with Comment.sty

Antoine wrote:Thanks, As far as I remember from trying out a few of these (versions.sty comes to mind) was that they had issues with verbatim's inside a comment. Will try again
Howdy,

That's not surprising. the verbatim environment is very unusual because basically has to turn off all processing (e.g., deactivate' the \) but still tell where it ends. The comment package overcomes that by writing that comment.cut file and having everything re-digested' when it's read back in; very clever. But it then has that unfortunate side effect as far as synctex is concerned. I'm not sure there is a solution since I believe that synctex is doing the right thing for the vast majority of cases.
Good Luck,
Herb Schulz
Herbert Schulz

Posts: 1489
Joined: Thu May 12, 2005 2:31 pm