如何才能使评论居中显示在页面底部 2 厘米以上?

如何才能使评论居中显示在页面底部 2 厘米以上?

正如标题所述,如何才能获得位于页面底部 2cm 上方居中的评论?

答案1

您可以使用 Tikz 来完成这些工作。

\documentclass[border=10pt,a4paper]{article}

\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node[yshift=2cm] (text) at (current page.south) {Your text}
\end{tikzpicture}
\end{document}

如果你需要在所有页面上使用它。你应该考虑使用fancyhdr

答案2

如果你有兴趣测试一个依赖于 LuaTeX 的新包,那么普拉塞特。目前它的功能还不是特别丰富,特别是在网格方面,但它所需的开销比加载要小TikZ

这是一个例子;编译如下lualatex

% compile with lualatex
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}% 'showframe' lets us see where normal text would go
\usepackage{placeat}
\placeatsetup{
% using A4 paper, make the grid use (approx.) 1cm intervals
  gridnumberx = 28,
  gridnumbery = 21,
  nogrid, % <-- removes the grid
}
% placeat doesn't support centered material (yet?)...
\newcommand*{\cbox}[1]{\makebox[0pt][c]{#1}}

\begin{document}

Normal text up here

\placeat(15,20){\cbox{Special text down here}}

\end{document}

答案3

我想说用随机说明符“b!”定义一个新的浮点数是解决问题最方便的方法:

\documentclass{article}
\usepackage{lipsum,microtype}
\usepackage{float}
  \newfloat{comment}{b!}{loc}

\makeatletter
\def\commentname{Comment}
\let\svd@comment=\comment
\let\svd@endcomment=\endcomment
\renewcommand{\comment}[1][b!]{%
  \svd@comment[#1]
  \small
  {\noindent\itshape\commentname.\space}}
\renewcommand{\endcomment}{%
  \vspace{2cm}\null
  \svd@endcomment}
\makeatother

\begin{document}
\lipsum[1-2]

\begin{comment}
  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{comment}

\lipsum[3-5]
\end{document}

替代:使用该textpos包,您可以轻松地将材料放置在页面上的绝对位置。缺点是它不会检测重叠。因此,您必须手动管理周围的文本:

\documentclass{article}
\usepackage{lipsum,microtype}
\usepackage{fp}
\usepackage[absolute]{textpos}
  \setlength{\TPHorizModule}{1pt}
  \setlength{\TPVertModule}{\TPHorizModule}

\makeatletter
\def\commentname{Comment}
\newcount\oddsidemarginvalue \oddsidemarginvalue62
\newcount\textwidthvalue \textwidthvalue345
\setlength{\oddsidemargin}{\the\oddsidemarginvalue pt}
\setlength{\textwidth}{\the\textwidthvalue pt}
\advance\oddsidemarginvalue by 72
\newcount\y@comment \y@comment630
\newdimen\commentheight
\makeatother

\begin{document}
\makeatletter
\lipsum[1-3]
  \setbox0=\vbox{% measuring the height of the comment
    \small
    {\noindent\itshape\commentname.}
    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.}
  \commentheight=\ht0 \advance\commentheight by \dp0
  \def\commentheightvalue{\strip@pt\commentheight}
  \FPround\commentheightvalue{\commentheightvalue}{0}
  \advance\y@comment by -\commentheightvalue
\begin{textblock}{\the\textwidthvalue}(\the\oddsidemarginvalue,\the\y@comment)
  \small% printing the actual comment body
  {\noindent\itshape\commentname.}
  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{textblock}
\y@comment630
\makeatother
\end{document}

请注意,最后一个例子可以很容易地包装到宏或环境中。现在,它只是环境设施的演示,textblock用于解决您的问题

相关内容