Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken references and citations ? #73

Open
labatfr opened this issue Aug 23, 2024 · 6 comments
Open

Broken references and citations ? #73

labatfr opened this issue Aug 23, 2024 · 6 comments

Comments

@labatfr
Copy link

labatfr commented Aug 23, 2024

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: #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
Copy link

leanhdung1994 commented Aug 25, 2024

Currently, Texpresso does not support \cite{} and \ref{}. You can see here #35 (comment). Yess, I encounter the same phenomenon, i.e., no window shows up when I run ./build/texpresso-tonic ./test/simple.tex.

@wu7zh
Copy link

wu7zh commented Aug 25, 2024

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
Copy link
Owner

let-def commented Aug 27, 2024

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:

  • for internal references, a first execution of latex produces a <document-name>.aux file to record which names are defined
  • a second execution reads the <document-name>.aux to resolve the names.

Complex documents often need more passes:

  • adding references might have changed some page number, so a third pass can be necessary to converge
  • supporting bibliography needs one pass to collect the works cited, then a run of BibTeX to resolve the citations into bibliographic entries, then more runs of LaTeX to insert the citations into the document (which can, again, change the page numbers, etc).
    Compilation is not even guaranteed to converge (this process often has the fixed point but not always :)).

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:

  • I plan to get rid of the dependency on Tectonic, in principle the workflow should work with TeXlive too but this needs some work
  • Built-in support for multiple passes is also possible, but a bit more involved and require integration with other tools; this is not a priority at the moment
  • There a few known bugs that make the workflow less reliable than it could be, but I have no time for development at the moment. I might be able to spend some time again on TeXpresso in a few months.

@leanhdung1994
Copy link

leanhdung1994 commented Aug 27, 2024

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

@DominikPeters
Copy link

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
Copy link

leanhdung1994 commented Aug 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants