10

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?

1
  • I'm sorry that the sample outputs do not match the MWE — will change the pictures soon. Commented Apr 2, 2013 at 14:06

3 Answers 3

7

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}
4
  • 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
    Commented Apr 2, 2013 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:-) Commented Apr 2, 2013 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 :) Commented Apr 2, 2013 at 14:00
  • 1
    @ralfix I should probably have used \csname @mpfootins\endcsname then it would have worked in both contexts Commented Apr 2, 2013 at 14:11
3

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}
2

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}
7
  • 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. Commented Apr 2, 2013 at 14:05
  • In that case I think you can use the tabu package with X[c] identifier.
    – cacamailg
    Commented Apr 2, 2013 at 14:08
  • @ralfix just add \centering or (much more efficiently) instead of tabularx use \parbox{12cm}{\centering....} Commented Apr 2, 2013 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
    Commented Apr 2, 2013 at 14:15
  • @cacamailg the tabu-solution does not hyphenate words – is there another identifier which does that? @DavidCarlisle another answere? :) Commented Apr 2, 2013 at 14:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .