我已经知道要\par\vspace*{\fill}
在页面底部对齐一段文本(下图,左);但我该如何使用来做到这一点tikz
?
current page.base
我能找到的唯一接近的东西是与-对齐anchor=south
,但它与页面底部对齐,如下图右所示(下面的代码;单击图像可获得完整分辨率):
以下是该图像使用的代码(均使用 进行编译pdflatex test.tex
):
左边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}
右边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}
生成图像:
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
非常感谢您的任何回答,
干杯!
答案1
这相对容易tikzpagenodes
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}
输出:
答案2
calc
我认为我已经设法用库将它放到我想要的位置tikz
,并计算coordinate
...但我很想知道是否存在这种对齐方式的默认设置(点击查看完整分辨率):
这是 MWE: (顺便说一句,我不知道为什么 footskip 应该按 0.5 缩放才能正确对齐;如果没有它,该框会略高于底部边缘)
\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}
好吧,我想,即使没有默认值,这也不算太糟糕...
干杯!