Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a minipage, and inside of it I have a footnote and a tikZ picture. Now my problem is, that the footnote text goes inside the last node of my tikZ picture. That is not what I want – and it's very weird actually.

Code and output

\documentclass{article}

\usepackage{tikz,lipsum}

\begin{document}

\begin{minipage}{\textwidth}
\lipsum[1]\footnote{a footnote}% I cannot use \footnotemark etc
    \begin{tikzpicture}[overlay, remember picture]% I need these two options
        \draw[ultra thick, black] (0,0) -- node[sloped,below,text width=12cm,text centered]
{\lipsum[4]} (11,-3);% the text has to have a maximal width
    \end{tikzpicture}
\end{minipage}

\end{document}

Screenshot

First workaround

When I remove the text width = 12cm completely, the footnote moves back under the end of the text:

Screenshot after workaround

But I need the text to have a maximal width. So this is not very satisfying. Any ideas?

share|improve this question
    
I'm sorry that the sample outputs do not match the MWE — will change the pictures soon. –  ralfix Apr 2 '13 at 14:06

3 Answers 3

up vote 6 down vote accepted

where we learn tikz uses minipage internally:-)

this saves and restores the footnotes to stop tikz seeing it, so the footnote comes in the right place, the rotated tikz picture overprints but I guess someone who knows tikz can fix that...

enter image description here

\documentclass{article}

\usepackage{tikz,lipsum}

\begin{document}

\begin{minipage}{\textwidth}
\lipsum[1]\footnote{a footnote}% I cannot use \footnotemark etc
    \setbox0\box\csname@mpfootins\endcsname
    \begin{tikzpicture}[overlay, remember picture]% I need these two options
        \draw[ultra thick, black] (0,0) -- node[sloped,below,text width=12cm,text centered]
{\lipsum[4]} (11,-3);% the text has to have a maximal width
    \end{tikzpicture}\global\setbox\csname@mpfootins\endcsname\box0
\end{minipage}

\end{document}
share|improve this answer
2  
TikZ normally uses an hbox to store the node content but when a line breaking is needed, it switches to a minipage to allow for text width or align=center etc such that the line breaks are respected and/or inserted. That's why removing text width works. –  percusse Apr 2 '13 at 13:45
1  
@percusse clearly yes although it probably ought just use \vbox{{\@parboxrerstore so an internal version of minipage that doesn't hijack footnotes. (although you could say that latex could handle nested minipages better:-) –  David Carlisle Apr 2 '13 at 13:53
    
Thank you, very nice! I use the code inside a custom package, so I had to change \csname@mpfootins\endcsname to \@mpfootins. But I really like the \csname-method, I think it is much nicer than a \makeatletter :) –  ralfix Apr 2 '13 at 14:00
1  
@ralfix I should probably have used \csname @mpfootins\endcsname then it would have worked in both contexts –  David Carlisle Apr 2 '13 at 14:11

This is why LaTeX is beautiful... Another solution :)

\documentclass{article}

\usepackage{tikz,lipsum}
\usepackage{footnote}

\begin{document}

\begin{minipage}{\textwidth}
\savenotes
\lipsum[1]\footnote{a footnote}% I cannot use \footnotemark etc
    \begin{tikzpicture}[overlay, remember picture]% I need these two options
        \draw[ultra thick, black] (0,0) -- node[sloped,below,text width=12cm,text centered]
{\lipsum[4]} (11,-3);% the text has to have a maximal width
    \end{tikzpicture}
\spewnotes
\end{minipage}

\end{document}
share|improve this answer

A possible solution (which is not a real solution) is to do something like:

\documentclass{article}

\usepackage{tikz,lipsum}
\usepackage{tabu}

\begin{document}

\begin{minipage}{\textwidth}
\lipsum[1]\footnote{a footnote}% I cannot use \footnotemark etc
    \begin{tikzpicture}[overlay, remember picture]% I need these two options
        \draw[ultra thick, black] (0,0) -- node[sloped,below]
{
    \begin{tabu}to 12cm {X[c]}
    \lipsum[4]
    \end{tabu}
} (11,-3);% the text has to have a maximal width
    \end{tikzpicture}
\end{minipage}

\end{document}
share|improve this answer
    
This is a nice (and a real!) solution, but I needed the text to be centered, not justified – I sometimes have only a few words "under the line", these get left-aligned in your solution. But you couldn't know, it wasn't clear from the MWE. –  ralfix Apr 2 '13 at 14:05
    
In that case I think you can use the tabu package with X[c] identifier. –  cacamailg Apr 2 '13 at 14:08
    
@ralfix just add \centering or (much more efficiently) instead of tabularx use \parbox{12cm}{\centering....} –  David Carlisle Apr 2 '13 at 14:09
    
I edited my answer to work with tabu and get the text centered. However, I think the previous comment by @DavidCarlisle probably is the best approach. –  cacamailg Apr 2 '13 at 14:15
    
@cacamailg the tabu-solution does not hyphenate words – is there another identifier which does that? @DavidCarlisle another answere? :) –  ralfix Apr 2 '13 at 14:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.