let-def / texpresso

TeXpresso: live rendering and error reporting for LaTeX
MIT License
416 stars 18 forks source link

Broken references and citations ? #73

Open labatfr opened 3 months ago

labatfr commented 3 months ago

Hi, I managed to compile texpresso and texpresso-tonic on my Mac version 14.6.1 using rust 1.80.1 To compile texpresso-tonic, I followed the recommendation found here: https://github.com/let-def/texpresso/issues/70 to update time from version 0.3.34 to version 0.3.36.

The command ./build/texpresso ./test/simple.tex gives me a window with the compiled .tex file that appears correctly.

However, as soon as I try to include references to sections, tables, figures, equations, pages, or try to cite references with bibtex, the file is created and displayed but I only get '?' instead of references.

On the other hand, if I call texpresso-tonic instead of texpresso, the references work, but the window no longer appears.

Is there anything special I need to do with texpresso to be able to use references and citations ?

Thanks !

leanhdung1994 commented 3 months ago

Currently, Texpresso does not support \cite{} and \ref{}. You can see here https://github.com/let-def/texpresso/issues/35#issuecomment-2016990533. Yess, I encounter the same phenomenon, i.e., no window shows up when I run ./build/texpresso-tonic ./test/simple.tex.

wu7zh commented 3 months ago

Nice that my comment could help you compile! Running texpresso-tonic will just run a normal compile of the (modified) tectonic compiler, so the is no window supposed to show up, thats what texpresso is for.

let-def commented 3 months ago

TeXpresso does not support hyperref (clickable links), but that should not prevent it from handling \cite{...} and \ref{...} the same way LaTeX does.

LaTeX supports them by doing multiple passes:

Complex documents often need more passes:

TeXpresso does only a single pass. To handle references and bibliography, it is necessary that the document has been compiled by LaTeX before.

What you can do is:

$ tectonic -X compile --keep-intermediates my-document.tex
$ texpresso my-document.tex

References and citations will be displayed. The tectonic command will have to be reran when the document structure and bibliography changes.

Notes:

  1. you can use texpresso-tonic in place of tectonic , they should behave the same for this task
  2. previously, xelatex from TeXlive was supported, but a recent update to TeXlive broke the compatibility

Some remarks on the future work:

leanhdung1994 commented 3 months ago

"Built-in support for multiple passes" is my biggest dream.

DominikPeters commented 3 months ago

It could make sense to add a command to the editor protocol to request a re-compile, which would then lead texpresso to call the equivalent of tectonic -X compile --keep-intermediates (or in the future another tex engine) as well as perhaps trigger other refreshes to the internal state of texpresso.

leanhdung1994 commented 3 months ago

It could make sense to add a command to the editor protocol to request a re-compile, which would then lead texpresso to call the equivalent of tectonic -X compile --keep-intermediates (or in the future another tex engine) as well as perhaps trigger other refreshes to the internal state of texpresso.

  1. The suggestion by @DominikPeters is a good quick interim solution. The mechanism you suggested was actually adopted by BaKoMa Tex. First, we define \label{abc}.
    • If we immediately call \eqref{abc} , then we get (??): image
    • If we press F5 twice to "refresh" the editor and then call \eqref{abc}, the the reference shows up correctly: image

I have to press F5 twice because I use package autonum.

  1. I guess the long-term solution by @let-def is more efficient but more involved and thus take time to implement.

    Resolve local references. I am not 100% clear how this will work, but I think it should be modeled roughly on the design of SyncTeX support. Backward references can be handled by scanning the existing part of the document. If the reference is not resolved this way, it is likely a forward reference: keep rendering until resolving the reference or ending the document.