xsim icon indicating copy to clipboard operation
xsim copied to clipboard

xsim and synctex

Open thorstengrothe opened this issue 7 years ago • 12 comments

Hello,

I'm converting all my exsheets exercises to xsim, so far it works really well. I found out that if the document is compiled with synctex one can only jump to the files named:

*-exercise-body.tex

Is there a way to jump directly to the source code and not to the *-body.tex files? synctex is a very very convinent way to work with - especially for long documents...

Regards Thorsten

thorstengrothe avatar Jun 23 '17 14:06 thorstengrothe

I don't know much about synctex but I am quite certain there is nothing a package author can do about it.

cgnieder avatar Jun 23 '17 15:06 cgnieder

This is the same problem: https://tex.stackexchange.com/questions/163951/ – no solution, though

cgnieder avatar Jun 23 '17 16:06 cgnieder

Ok, thanks for your research, maybe the problem will be fixed some day...until now I will live with it :-)

thorstengrothe avatar Jun 23 '17 17:06 thorstengrothe

I wonder if there is a way to make an xsim option to put only the verbatim environments in their own separate source document, rather than doing this unconditionally on the entire text of every exercise and solution. Then, outside of the verbatim environment, the source links would link back to the original source.

I'll bet the problem could be solved in this way: give an option, disabled by default, to turn off the "separate exercise/solution *.tex files". Then, introduce a new environment, xsimverbatim, which, if this option is enabled, would be required to surround any verbatim environment used. For example:

Here is some verbatim text:
\begin{xsimverbatim}
\begin{verbatim}
def f(x):
    return x+1
\end{verbatim}
\end{xsimverbatim}
Here is some code in another verbatim environment:
\begin{xsimverbatim}
\begin{lstlisting}[language=Python]
def f(x):
    return x+1
\end{lstlisting}
\end{xsimverbatim}

Then xsim could pull the content out of each xsimverbatim environment and put it into a separate file, similarly to what is currently done with the exercise and solution environments. Similarly, there could be a new command \xsimverb for inline verbatim text: \xsimverb{\verb!x++;!}

The idea is that xsim wouldn't have to do much special processing or know anything about the verbatim text. One could use xsimverbatim and \xsimverb anywhere, without having to have a verbatim environment inside of it. It's just an instruction to put the contents in a separate file before running pdflatex.

Update: I read the documentation more carefully and saw there already is something like this in the xsimverb package, although it seems to require some boilerplate compared to simply having a new environment. So it seems that the above could be fairly simply implemented with an option to disable the writing of exercise/solution-body.tex files.

dave-doty avatar Mar 05 '18 17:03 dave-doty

I have thought about this and not yet dismissed it completely. There is a good chance I will implement it when I find the time. The default behaviour will stay the same, though, I think.

cgnieder avatar Mar 12 '18 14:03 cgnieder

I can only speak for me. At the moment I'm using exsheets because synctex is working fine with it. Synctex is essential for my workflow, so I would appreciate this feature very much.

thorstengrothe avatar Mar 13 '18 18:03 thorstengrothe

I'd like to second this request, not only because synctex takes me to the wrong file, but also because in AUCTeX (I don't know about other LaTeX environments), jumping to an error also takes me to the temp file, rather than to my main document. I'm actually trying out exsheets right now for these very reasons, even though I know it's deprecated.

BTW, doesn't issue #30 address the same issue?

joostkremers avatar May 21 '18 11:05 joostkremers

I am planning to add a solution as an alternative to the current behavior. I do not have as much time as I used to for (La)TeX currently. This will come one time… (https://github.com/cgnieder/xsim/issues/30#issuecomment-395957625)

cgnieder avatar Jun 09 '18 10:06 cgnieder

I'd also welcome a fix for this. I recently switched from exsheets to xsim (found out that the former is deprecated because it seemingly became incompatible with a change in the newest texlive). However, not having proper synctex support is really annoying. Actually I don't care at all about verbatim environments in my exercise sheets, so even an option to disable external files while sacrificing verbatim support would be fine for me.

In any case, thanks for the work on both exsheets and xsim :).

pitkling avatar Apr 04 '19 13:04 pitkling

I have implemented the experimental package option no-files (official update to CTAN will come in the next days…). For the time being this does not allow verbatim material when used.

\usepackage[no-files]{xsim}

Feedback (problems? ... ) very welcome!

cgnieder avatar Oct 03 '19 17:10 cgnieder

Is there any way to make this more granular so that verbatim material is allowed, and it will generate extra files (with their associated source link problems), but any exercise not using verbatim environments could be given the option [no-file] and would remain inline (and have working source links)?

dave-doty avatar Oct 03 '19 19:10 dave-doty

Probably, yes. But I don't expect this to be happening soon. It would require significant (!) changes to existing code.

cgnieder avatar Oct 03 '19 20:10 cgnieder