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

Is xr's \cite working properly? #1588

Open
LecrisUT opened this issue Dec 18, 2024 · 9 comments
Open

Is xr's \cite working properly? #1588

LecrisUT opened this issue Dec 18, 2024 · 9 comments
Assignees
Labels
bug (improve documentation) nothing really wrong but documentation could be better category tools fixed in dev Fixed in development branch, not in stable release

Comments

@LecrisUT
Copy link

LecrisUT commented Dec 18, 2024

Brief outline of the bug

I think this issue is a bit more difficult to create a MWE for me, but basically I tried to do something along the lines of

\usepackage{xr-hyper}  %Note that using `xr` only has the same outcome
\externaldocument{foo}

\begin{document}
    \cite{bar}
\end{document}

But this formats the \cite rather weird, e.g.:
Screenshot_20241218_230157

I believe the result should be only the text 15 in that part. Some light digging, I can see that the .aux file has the content like:

\bibcite{Yost_2019}{{15}{2019}{{Yost\ \emph  {et~al.}}}{{Yost, Yao,\ and\ Kanai}}}

The citation is built from a revtex4-2 document with BibTeX compiler.

Are there any references or examples of xr working with \cite to compare with?

I am using the LaTeX version from Fedora41

Minimal example showing the bug

Partially provided in the previous section

Log file (required) and possibly PDF file

Partially provided in the previous section


Edit: I guess this is the issue documented about natbib?

@u-fischer
Copy link
Member

Please show a MWE. Without it it is impossible to debug this. Be aware that revtex4-2 is an external class, a bug report should not use it. Use article instead.

@LecrisUT
Copy link
Author

Could I quickly get some feedback if this is related to natbib, I saw maybe some related issues:

If so is there anything that can be done to patch this?

@u-fischer
Copy link
Member

I have no idea. That's why I need an small example and you are the one who can provide it, as you already have an example that you can minimize.

@LecrisUT
Copy link
Author

LecrisUT commented Dec 18, 2024

Well, I have just tried to include \usepackage{natbib} and that kinda resolved my issue:
Screenshot_20241218_232205

It could be good to document that when using xr with \cite you should also import the same natbib/biblatex that the original project used. Still don't know how to control and have it display the cite number instead of the expanded text, but it seems I have a foothold to move forward from. (edit: that was resolved with this)

@FrankMittelbach
Copy link
Member

Cristian: to determine if there is a bug (in code we maintain) we need an example that can be processed, not bits and pieces that we need to stick together and guess what you have in front of you. Yes that is work for you, but producing it at our end is even more work, because we need to guess what to put in and also because we aren't dealing with one issue but with many that people are having of believing to have. Even in a situation like yours this is possible, for example, the second file foo.tex could be attached via \begin{filecontents} but even just supplying both stripped down to a bare minimum would already help a lot.

But I think your guess is right: natbib generates and uses its own format of citation code that goes into the aux file, different from what LaTeX does by default (and also different from what a few other packages do, e.g., chicago

\bibitem[\protect\citeauthoryear{Goossens, Rahtz, and Mittelbach} {Goossens et~al.}{1997}]{LGC97}

jurabib

\bibitem[{Goossens\jbbfsasep Rahtz\jbbstasep Mittelbach\jbdy {1997}}%
{}{{0}{}{book}{1997}{}{}{}{xxi + 554}{Reading, MA, USA\bpubaddr {} Ad{\-d}i{\-s}on-Wes{\-l}ey Longman\bibbdsep {} 1997}}{{The {\LaTeX} Graphics Companion: Illustrating Documents with {\TeX} and {PostScript}}% {}{}{}{}{}{}{}{}}]{LGC97}

and with biblatex it would be again totally different (copy pages from LaTeX Companion Part-II p488). So bottom line, xr works only with documents using the same citation storage method. And yes, that should perhaps be mentioned in the xr documentation.

@FrankMittelbach FrankMittelbach added category tools bug (improve documentation) nothing really wrong but documentation could be better labels Dec 18, 2024
@FrankMittelbach
Copy link
Member

@davidcarlisle Xmas present

@davidcarlisle
Copy link
Member

@LecrisUT @FrankMittelbach the documentation does already call out that including citations from another document may not work

% Many packages have variant citation commands (natbib,
% biblatex,....) and the external document may or may not have used
% hyperref. Because of these differences the citation linking may not
% always work, it can be disabled by specifying \texttt{[nocite]} after the

I suppose it could also explicitly mention that it is more likely to work if both documents use the same citation packages, but I'm inclined to close this with no change as I think that's implied by the current text.

@LecrisUT
Copy link
Author

I find the documentation too cryptic and too defensive, pushing the users away from it. Would prefer showing what is the intended interface, some common issues, etc. In the current documentation it is unclear that you would be able to use \cite and its derivatives, instead I had to guess by the existence of nocite and look into the source to see if it would use some other commands or \cite directly

@davidcarlisle
Copy link
Member

well it's defensive for a reason.. I don't want to over-promise if things will work, even if both documents use the same set of packages they may have made arbitrary changes to the internal cite data format and the external document mechanism may or may not work, I really have no idea. I think the most I could do is add an extra line saying that external citation commands will work most reliably if both documents use the same set of citation related packages.

davidcarlisle added a commit that referenced this issue Dec 22, 2024
* additional documentation for #1588

* Update required/tools/xr.dtx

Co-authored-by: Yukai Chou <[email protected]>

---------

Co-authored-by: Frank Mittelbach <[email protected]>
Co-authored-by: Yukai Chou <[email protected]>
@davidcarlisle davidcarlisle added the fixed in dev Fixed in development branch, not in stable release label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (improve documentation) nothing really wrong but documentation could be better category tools fixed in dev Fixed in development branch, not in stable release
Projects
None yet
Development

No branches or pull requests

4 participants