我想使用页面上的坐标精确选择我的小页面的起始位置。到目前为止,我有以下内容,
\documentclass{article}
\begin{document}
\begin{minipage}[x=10cm,y=5cm]{8em}
The quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog. the quick brown fox jumps right over the lazy
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog. the quick brown fox jumps right over the lazy
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog.
\end{minipage}
\end{document}
但是这些坐标对迷你页面的定位没有影响。有什么办法吗?
答案1
包裹textpos
textblock*
例如,提供绝对定位的环境。
\documentclass{article}
\usepackage[absolute]{textpos}
\begin{document}
\begin{textblock*}{8em}(10cm,5cm)
The quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog. the quick brown fox jumps right over the lazy
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog. the quick brown fox jumps right over the lazy
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog.
\end{textblock*}
\end{document}
注意:若没有选项,absolute
位置将相对于文本区域而不是相对于页面。
使用包裹eso-pic
也有可能:
\documentclass{article}
\usepackage{eso-pic}
\begin{document}
\AddToShipoutPicture*{%
\AtPageUpperLeft{%
\put(10cm,-5cm){%
\begin{minipage}[t]{8em}
The quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog. the quick brown fox jumps right over the lazy
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog. the quick brown fox jumps right over the lazy
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog.
\end{minipage}
}%
}%
}
\mbox{}% the hook code is only printed, if the page is not empty
\end{document}
请参阅软件包的手册来获取更多信息。
答案2
我假设您考虑将内容绝对放置在minipage
独立于常规内容的位置。
您可以使用shipout/background
钩子和\put(X,Y){<content>}
来访问绝对坐标并将对象放置在您的位置。请注意,坐标从左上角开始。
例如,下面的代码minipage
在第二页的中心渲染了。我添加了颜色以更好地区分文本和背景内容:
\documentclass{article}
\usepackage{xcolor}
\usepackage[nopar]{kantlipsum}
\begin{document}
\kant[1-3]
\clearpage
\AddToHookNext{shipout/background}{\put(0.5\dimexpr\pagewidth-8em,-0.5\pageheight){%
\fcolorbox{red}{yellow!50}{\color{blue}%
\begin{minipage}{8em}
The quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog. the quick brown fox jumps right over the lazy
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog. the quick brown fox jumps right over the lazy
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog.
\end{minipage}}}}
\kant[4][1-6]
\end{document}
答案3
您可以通过 tikz 节点插入文本,而不是使用minipage
。以下示例中的坐标相对于页面左上角:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node[text width=8em] at (3cm,-5cm) {The quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog. the quick brown fox jumps right over the lazy
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog. the quick brown fox jumps right over the lazy
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox
jumps right over the lazy dog.};
\end{tikzpicture}
\end{document}