5

I already know about \par\vspace*{\fill} to align a piece of text at the bottom of page (image below, left); but how do I do this with tikz?

Only thing close I can find is aligning to current page.base with anchor=south - but that aligns to bottom of page, as shown on image below right (code below; click on image for full resolution):

test.png: left without, right with tikz

Here is the code used for this image (both compiled with pdflatex test.tex):

left side test.tex:

\documentclass[letterpaper,12pt]{article}

% \typeout{ == \the\paperwidth / \the\paperheight ==}
% \typeout{ == \the\pdfpagewidth / \the\pdfpageheight ==}
\pdfpagewidth=\paperwidth \pdfpageheight=\paperheight

% to extract numbers from lengths:  % tex.se:15001
% NOTE: \getlength gets numeric portion as pt always;
\makeatletter
  \newcommand*{\getlength}[1]{\strip@pt#1}
\makeatother

\usepackage{lipsum}


\begin{document}

  % display page margins based on \textwidth/height
  \edef\mw{\getlength{\textwidth}}
  \edef\mh{\getlength{\textheight}}
  \edef\mp{\getlength{\parindent}}
  \newlength{\tmv}
  \setlength{\tmv}{\textwidth}
  \addtolength{\tmv}{-\parindent}
  \edef\mv{\getlength{\tmv}}
  \begin{picture}(0,0)
  \put(-\mp,0) {\line(1,0){\mw}}
  \put(-\mp,0) {\line(0,-1){\mh}}
  \put(\mv,0) {\line(0,-1){\mh}}
  \put(-\mp,-\mh) {\line(1,0){\mw}}
  \end{picture}

  \lipsum[1]

  \par\vspace*{\fill} % \vfill no dice here

  \frame{\begin{minipage}{\textwidth}%
    \centering%
    Please consider

    this information

    very carefully.
  \end{minipage}}

\end{document}

right side test.tex:

\documentclass[letterpaper,12pt]{article}

% \typeout{ == \the\paperwidth / \the\paperheight ==}
% \typeout{ == \the\pdfpagewidth / \the\pdfpageheight ==}
\pdfpagewidth=\paperwidth \pdfpageheight=\paperheight

% to extract numbers from lengths:  % tex.se:15001
% NOTE: \getlength gets numeric portion as pt always;
\makeatletter
  \newcommand*{\getlength}[1]{\strip@pt#1}
\makeatother

\usepackage{lipsum}
\usepackage{tikz}

\begin{document}

  % display page margins based on \textwidth/height
  \edef\mw{\getlength{\textwidth}}
  \edef\mh{\getlength{\textheight}}
  \edef\mp{\getlength{\parindent}}
  \newlength{\tmv}
  \setlength{\tmv}{\textwidth}
  \addtolength{\tmv}{-\parindent}
  \edef\mv{\getlength{\tmv}}
  \begin{picture}(0,0)
  \put(-\mp,0) {\line(1,0){\mw}}
  \put(-\mp,0) {\line(0,-1){\mh}}
  \put(\mv,0) {\line(0,-1){\mh}}
  \put(-\mp,-\mh) {\line(1,0){\mw}}
  \end{picture}

  \lipsum[1]

  \begin{tikzpicture}[overlay,remember picture,inner sep=0pt, outer sep=0pt]

    \path[anchor=south] (current page.base) node[above] (textInfo) {% (286.45807,94.70213)
      \frame{\begin{minipage}{\textwidth}%
        \centering%
        Please consider

        this information

        very carefully.
      \end{minipage}}
    };
  \end{tikzpicture}

\end{document}

To generate image:

convert -density 150 -bordercolor LimeGreen -border 2 test.pdf test1.png #left
convert -density 150 -bordercolor LimeGreen -border 2 test.pdf test2.png #right
montage test1.png test2.png -geometry +2+2 -tile 2x1 test.png

Many thanks in advance for any answers,
Cheers!

sdaau
  • 17,079
  • 1
    Why don't you just use the same \vspace*{\fill} approach with the tikzpicture? The tikzpicture (without the overlay) is treated just like a normal text object, so it will be moved to the bottom of the page as well. – Jake May 16 '12 at 10:34
  • Thanks for that, @Jake - I was just wandering if there was some special anchor or something that was tikz-specific, and that I had missed from the documentation... And I wasn't sure if tikzpicture is treated like a text object. Maybe you can post your comment as an answer so I can accept it? Cheers! – sdaau May 16 '12 at 10:55
  • 1
    I would use \node [draw,..] instead of \frame{..}. You can set inner sep=0pt if you don't want any separation. – Martin Scharrer May 16 '12 at 12:21
  • @Jake - I just came to a situation where using a Tikz "native" solution turned out better: I was using tikzpagenodes as in the answer, in a document where I redefine \paperwidth/height; turns out, I made a typo there - and the tikzpagenodes would not align at bottom correctly (which is what forced me to debug, and find and correct the typo) - for some reason, the \vspace*{\fill} approach didn't demonstrate that problem in the same document. Cheers! – sdaau May 18 '12 at 11:12

2 Answers2

4

This is relatively easy with the tikzpagenodes package by Martin Scharrer:

\documentclass[letterpaper,12pt]{article}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\begin{document}

  \lipsum[1]

  \begin{tikzpicture}[overlay,remember picture,inner sep=0pt, outer sep=0pt]

    \node[anchor=south] at (current page text area.south) {% 
      \frame{\begin{minipage}{\textwidth}%
        \centering%
        Please consider

        this information

        very carefully.
      \end{minipage}}
    };
  \end{tikzpicture}

\end{document}

Output:

enter image description here

Daniel
  • 37,517
1

I think I managed to get it where I want to with the calc library of tikz, and calculating a coordinate... But I'd love to know if there is otherwise a kind of default for this kind of alignment (click for full res):

Here is the MWE: (btw, I have no idea why the footskip should be scaled with 0.5 so it aligns correctly; without it, the box stands a little above the bottom margin)

\documentclass[letterpaper,12pt]{article}

% \typeout{ == \the\paperwidth / \the\paperheight ==}
% \typeout{ == \the\pdfpagewidth / \the\pdfpageheight ==}
\pdfpagewidth=\paperwidth \pdfpageheight=\paperheight

% to extract numbers from lengths:  % tex.se:15001
% NOTE: \getlength gets numeric portion as pt always;
\makeatletter
  \newcommand*{\getlength}[1]{\strip@pt#1}
\makeatother

\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{calc} % for let

\begin{document}

  % display page margins based on \textwidth/height
  \edef\mw{\getlength{\textwidth}}
  \edef\mh{\getlength{\textheight}}
  \edef\mp{\getlength{\parindent}}
  \newlength{\tmv}
  \setlength{\tmv}{\textwidth}
  \addtolength{\tmv}{-\parindent}
  \edef\mv{\getlength{\tmv}}
  \begin{picture}(0,0)
  \put(-\mp,0) {\line(1,0){\mw}}
  \put(-\mp,0) {\line(0,-1){\mh}}
  \put(\mv,0) {\line(0,-1){\mh}}
  \put(-\mp,-\mh) {\line(1,0){\mw}}
  \end{picture}

  \lipsum[1]

  \begin{tikzpicture}[overlay,remember picture,inner sep=0pt, outer sep=0pt]

    \path
      let \p1=(current page.center)
      in coordinate (BP) at (\x1,\y1-0.5\textheight-0.5\footskip);

    \path[anchor=south] (BP) node[above] (textInfo) {% 
      \frame{\begin{minipage}{\textwidth}%
        \centering%
        Please consider

        this information

        very carefully.
      \end{minipage}}
    };
  \end{tikzpicture}

\end{document}

Well, even without a default, this isn't too bad, I guess...
Cheers!

Martin Scharrer
  • 262,582
sdaau
  • 17,079