GeneralWhat the Hell is happening with this small code ?

LaTeX specific issues not fitting into one of the other forums of this category.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What the Hell is happening with this small code ?

Post by Cham »

I'm now getting something really weird. The footnote isn't working correctly with this simple code. Why ? What is happening here ?

Code: Select all

\documentclass[10pt,letterpaper]{revtex4}
\usepackage{xcolor}
\usepackage[colorlinks,urlcolor=red]{hyperref}

\begin{document}

Test\footnote{Test \url{http://fr.wikipedia.org/wiki/Polytrope}.}.

\end{document}
The console gives me this :
Runaway argument?
{Test
./TSWLatexianTemp_000675.end:1: Paragraph ended before \@doendnote was complete.
<to be read again>
\par
l.1 \@doendnote{endnote1}{Test \par
\protect \url {http://fr.wikipedia.org/wiki/Polytrope}.}
./TSWLatexianTemp_000675.end:1: Extra }, or forgotten \endgroup.
l.1 ... {http://fr.wikipedia.org/wiki/Polytrope}.}

)

Package natbib Warning: Empty `thebibliography' environment on input line 9.


Package natbib Warning: There were undefined citations.
Last edited by Cham on Sun May 28, 2017 7:11 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

What the Hell is happening with this small code ?

Post by cgnieder »

TeX and thus LaTeX knows short macros and long macros. The difference is that the argument of short macros must not contain the token \par or a blank line, resp.

Code: Select all

% Plain TeX:
\def\shortmacro#1{#1}
\long\def\longmacro#1{#1}

% LaTeX:
\newcommand*\shortmacro[1]{#1}
\newcommand\longmacro[1]{#1}
Whenever \par turns up in the argument of a short macro you get an error message like

Code: Select all

! Paragraph ended before \shortmacro was complete.
<to be read again> 
                   \par
In your case the problem is that \@doendnote is a short macro as

Code: Select all

\makeatletter
\show\@doendnote
\makeatother
shows:

Code: Select all

> \@doendnote=macro:
#1#2->\bibitem {#1}#2.
This also shows a possible solution:

Code: Select all

\makeatletter
\renewcommand\@doendnote[2]{\bibitem{#1}#2}
\makeatother
Complete working example:

Code: Select all

\documentclass[10pt,letterpaper]{revtex4}
\usepackage{xcolor}
\usepackage[colorlinks,urlcolor=red]{hyperref}

\makeatletter
\renewcommand\@doendnote[2]{\bibitem{#1}#2}
\makeatother

\begin{document}

Test\footnote{Test \par \url{http://fr.wikipedia.org/wiki/Polytrope}.}.
 
\end{document}
site moderator & package author
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What the Hell is happening with this small code ?

Post by Cham »

I don't understand. What is the culprit here ? I was using this kind of codes before without any troubles. This problem is new today !
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

What the Hell is happening with this small code ?

Post by cgnieder »

Cham wrote:I don't understand. What is the culprit here ?
Like I said above: the culprit is that revtex4's \@doendnote is a so-called short macro!
Cham wrote:I was using this kind of codes before without any troubles. This problem is new today !
Then you made an update which changed something. But actually I don't believe that and don't believe you: `revtex4` hasn't changed since 2001/08/02 (according to its manual) so the same code would have given the same error for the last 16 years.

Of course it is different with other document classes where \footnote has another definition…
site moderator & package author
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What the Hell is happening with this small code ?

Post by Cham »

No, there's something fishy in my document. I just changed the whole preamble (from another document which compiles correctly), and yet I still get a bad footnote. I don't understand what is happening.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

What the Hell is happening with this small code ?

Post by cgnieder »

Cham wrote:No, there's something fishy in my document. I just changed the whole preamble (from another document which compiles correctly)
Does it use the same document class? Does one or the other document redefine the \footnote command? Maybe some package you're loading in the one document and not the other? There must be differences in the preambles of both documents otherwise either both would compile or both would through an error! I explained to you where the error is from in your MWE. Now apply the fix I gave you to your real document. If it still gives an error make a new Infominimal working example including the fix and post it here and we'll see what's happening…
site moderator & package author
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What the Hell is happening with this small code ?

Post by Cham »

I'm using exactly the same preamble (document class and all) as another document. Both documents are using footnotes. Yet, one compiles fine, the other one gives a bad footnote ! What the ... !?
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

What the Hell is happening with this small code ?

Post by cgnieder »

Cham wrote:I'm using exactly the same preamble (document class and all) as another document. Both documents are using footnotes. Yet, one compiles fine, the other one gives a bad footnote !
And in both documents you're using a \par (or a blank line) in the footnote? If yes then I'm out of answers without yet another Infominimal working example which lets me reproduce the error. Or you're using a \par (or a blank line) in the footnote only in the one which gives the error? If yes then return to my first answer read it again carefully.
site moderator & package author
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What the Hell is happening with this small code ?

Post by Cham »

Apparently, there's a link with the following code, in the preamble, which adds a diagonal watermark on all pages (both documents are using the same code). One document compiles fine, the other one gives a broken footnote. Desactivating that code fixes the problem, so I guess this is the culprit :

Code: Select all

\usepackage{tikz}
\usepackage[printwatermark]{xwatermark}
\newsavebox\mybox
\savebox\mybox{\tikz[color=red,opacity=0.1]\node{\bfseries\sffamily POUR LE PROF !};}
\newwatermark*[allpages,angle=45,scale=8,textalign=center,height=\paperheight,width=\paperwidth,xpos=-25,ypos=25
]{\usebox\mybox}
Last edited by Cham on Sun May 28, 2017 6:55 pm, edited 1 time in total.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What the Hell is happening with this small code ?

Post by Cham »

cgnieder wrote:
Cham wrote:I'm using exactly the same preamble (document class and all) as another document. Both documents are using footnotes. Yet, one compiles fine, the other one gives a bad footnote !
And in both documents you're using a \par (or a blank line) in the footnote?
Well, there is NO \par command in both files !
Post Reply