yochju / latex-makefile

Automatically exported from code.google.com/p/latex-makefile
Other
0 stars 0 forks source link

latex should be run once more if there is natbib + hyperref back-references #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Back-references are hyper links in the bibliography that return to pages
that have citations. The problem is that if I use natbib to order the
citations with hyperref back-references, the Makefile doesn't run latex
enough times to make it happen.

The problem is that neither hyperref nor natbib will warn you that you need
to re-run so 
1. I just submitted a bug to the maintainers of the packages
2. In the mean time, I suggest a new macro to be added which would be
triggered if FORCED_ADDITIONAL_LATEX_PASS is on or something. That can
always come handy for somebody else later.

Below is an example demonstrating the bug. Note that the bug happens with
bibtex too. Observe how a magical link appears after the item in the
bibliography if you compile twice.

Also, please note that .brf files are generated by the hyperref package
while processing the tex file so they should probably be added to the
auxiliary clean targets.

That's all :D

===========================
\documentclass{article}
\usepackage[sectionbib,square,sort,compress]{natbib}
\usepackage[pagebackref=true]{hyperref}
\begin{document}
a citation:~\cite{lamport94}
\begin{thebibliography}{9}
\bibitem{lamport94}
  Leslie Lamport,
  \emph{\LaTeX: A Document Preparation System}.
  Addison Wesley, Massachusetts,
  2nd Edition,
  1994.
\end{thebibliography}
\end{document}

Original issue reported on code.google.com by fdemes...@gmail.com on 7 Nov 2009 at 8:22

GoogleCodeExporter commented 9 years ago
Actually, it is even easier to just unroll the last iteration of the loop...
The whole world is going to compile once more but who cares, it's so much 
faster than
dvitops and pstopdf that it really doesn't matter....

my fix:

    if [ x"$$run" = x"1" ]; then \
        $(call remove-files,$@.1st.make); \
        for i in 2 3 4 5; do \
            $(if $(findstring 3.79,$(MAKE_VERSION)),\
                $(call echo-build,$*.tex,$@,$$$$i),\
                $(call echo-build,$*.tex,$@,$$i)\
            ); \
            $(call run-latex,$*); \
            $(call test-run-again,$*) || break; \
        done; \
+        $(if $(findstring 3.79,$(MAKE_VERSION)),\
+            $(call echo-build,$*.tex,$@,$$$$i),\
+            $(call echo-build,$*.tex,$@,$$i)\
+        ); \
+        $(call run-latex,$*); \
   else \
        $(MV) $@.1st.make $@; \
    fi; \

Original comment by fdemes...@gmail.com on 7 Nov 2009 at 8:45

GoogleCodeExporter commented 9 years ago
Oh, one probably needs to add the following line too :)

 i="final";\

Original comment by fdemes...@gmail.com on 7 Nov 2009 at 10:14

GoogleCodeExporter commented 9 years ago
Interesting idea in general, but this patch concerns me a bit.  It turns out 
that an extra 
invocation of LaTeX is only cheap in some circumstances.  If building a beamer 
presentation or a large dissertation, it's a huge pain in the neck.

I'll take a look and see if there is some way we can figure out that an extra 
run is 
needed automatically.

Original comment by shiblon on 7 Nov 2009 at 7:36

GoogleCodeExporter commented 9 years ago
It's fixed upstream and issues a rerun warning now.

From Oberdiek: "In case of backref: To improve the situation I have updated to 
1.29:
It adds a rerun warning in case of pdfTeX/LuaTeX based on the MD5 sum
and the file size."

I couldn't check the code yet since it's not public but I will test it against 
the
latex-makefile. Note that .brf files still need to be replaced though.

Original comment by fdemes...@gmail.com on 14 Nov 2009 at 10:44

GoogleCodeExporter commented 9 years ago
typo: 
.brf files still need to be deleted though.

Original comment by fdemes...@gmail.com on 14 Nov 2009 at 10:45

GoogleCodeExporter commented 9 years ago
Awesome that you got it fixed upstream.  The brf deletion is fixed in 
r631595c796da.  
Also in version 2.1.36, available as a download.

Original comment by shiblon on 15 Nov 2009 at 5:01

GoogleCodeExporter commented 9 years ago
I confirm that it works with the new upstream code, including deletion of .brf 
files.

Just for reference, the new warnings look like this:

Package hyperref Warning: Rerun to get outlines right
(hyperref)                or use package `bookmark'.

Package backref Warning: Rerun to get bibliographical references right.

Original comment by fdemes...@gmail.com on 15 Nov 2009 at 9:51

GoogleCodeExporter commented 9 years ago
OK - just to confirm, then.  The makefile is properly detecting this new rerun 
warning 
from the upstream fix, and running enough times now?

Original comment by shiblon on 15 Nov 2009 at 3:20

GoogleCodeExporter commented 9 years ago
Yes it is.

Original comment by fdemes...@gmail.com on 15 Nov 2009 at 4:09

GoogleCodeExporter commented 9 years ago
Excellent - marking verified.

Original comment by shiblon on 15 Nov 2009 at 4:32