
我正在編寫一個文檔類,其中我想在文字區域的底部、腳註之後放置一行文本,以便其位置始終完全固定。對此的解決方案如下:
\documentclass{article}
\usepackage{lipsum,graphicx}
\title{A sample title}
\author{John Doe}
\makeatletter
\def\@maketitle{%
\newpage
\null
\vskip 2em%
\begin{center}%
\let \footnote \thanks
{\LARGE \@title \par}%
\vskip 1.5em%
{\large
\lineskip .5em%
\begin{tabular}[t]{c}%
\@author
\end{tabular}\par}%
\vskip 1em%
{\large \@date}%
\end{center}%
\begin{figure}[!b]
\copyright\ 2022 John Doe \hfill Department of Mathematics
\end{figure}
\par
\vskip 1.5em
}
\makeatother
\begin{document}
\maketitle
Text goes here\footnote{A footnote} and\footnote{Another footnote}
\lipsum[2]
\end{document}
但由於某些原因,我不想使用浮動環境。你能建議我另一個解決方案(最好不要加載額外的包)嗎?
答案1
可以在頁面上對文字進行絕對定位。例如,tikz 提供了執行此操作的方法。
如果最近的 LaTeX 版本正在使用,其中 Shipout-hooks 可用,您可以將程式碼新增至掛鉤shipout/foreground
。
鉤子shipout/foreground
指的是左上角(0,0)位於頁面左上角、單位長度為1pt的圖片環境。
(對於頁面上發生的事情,座標的 y/第二分量需要為負。最近在環境中發布的 LaTeX 版本不需要picture
關心規範化\dimexpr
和長度寄存器,因為它是自動完成的。)\unitlength
\documentclass[twoside]{article}
\csname @ifundefined\endcsname{pagewidth}{}{\pagewidth=\paperwidth}%
\csname @ifundefined\endcsname{pdfpagewidth}{}{\pdfpagewidth=\paperwidth}%
\csname @ifundefined\endcsname{pageheight}{}{\pageheight=\paperheight}%
\csname @ifundefined\endcsname{pdfpageheight}{}{\pdfpageheight=\paperheight}%
\usepackage{lipsum}
\title{A sample title}
\author{John Doe}
\makeatletter
\newcommand\foo[1]{#1}
\def\@maketitle{%
\newpage
% If you want this on the titlepage only, use \AddToHookNext instead of \AddToHook
\AddToHook{shipout/foreground}{%
\put(\dimexpr 1in+\ifodd\thepage\oddsidemargin\else\evensidemargin\fi\relax,
\foo{\dimexpr-\paperheight+.5\dimexpr\paperheight-(1in+\topmargin+\headheight+\headsep+\textheight+\footskip)+\ht\strutbox\relax\relax})%
{%
\hbox to\textwidth{\copyright\ 2022 John Doe \hfill Department of Mathematics}%
}%
}
\null
\vskip 2em%
\begin{center}%
\let \footnote \thanks
{\LARGE \@title \par}%
\vskip 1.5em%
{\large
\lineskip .5em%
\begin{tabular}[t]{c}%
\@author
\end{tabular}\par}%
\vskip 1em%
{\large \@date}%
\end{center}%
\par
\vskip 1.5em
}
\makeatother
\begin{document}
\maketitle
Text goes here\footnote{A footnote} and\footnote{Another footnote}
\lipsum[2]
\newpage
Text goes here\footnote{A footnote} and\footnote{Another footnote}
\lipsum[2]
\end{document}
如果使用的 LaTeX 版本不是最新的,請考慮載入該套件內幕圖片:
下面的程式碼提供了一個範例,其中命令\AddToShipOutPicture
其中包的命令內幕圖片與圖片環境相結合,其中該命令\put
可用於定位文字。
\documentclass[twoside]{article}
\usepackage{lipsum,eso-pic}
\title{A sample title}
\author{John Doe}
\makeatletter
\newcommand\ConvertToUnitlength[1]{%
\strip@pt\dimexpr#1*65536/\number\dimexpr\unitlength\relax\relax
}%
\def\@maketitle{%
\newpage
\null
\vskip 2em%
\begin{center}%
\let \footnote \thanks
{\LARGE \@title \par}%
\vskip 1.5em%
{\large
\lineskip .5em%
\begin{tabular}[t]{c}%
\@author
\end{tabular}\par}%
\vskip 1em%
{\large \@date}%
\end{center}%
% If you want this on every page, use \AddToShipoutPicture.
% If you want this on the title-page only, use \AddToShipoutPicture*.
\AddToShipoutPicture{%
\vbox to \paperheight{%
\hsize=\paperwidth
%----------------------------------------------------
% Within the \vbox do whatever you like:
% e.g., use a picture-environment:
%----------------------------------------------------
\setlength{\unitlength}{1cm}%
\begin{picture}(\ConvertToUnitlength{\paperwidth},
\ConvertToUnitlength{\paperheight})(0,0)%
% Inside this picture 0,0 is the bottom left corner.
% Unit is cm.
% If you wish to use length-parameter or \dimexppr, you can use \ConvertToUnitlength.
% With recent LaTeX \ConvertToUnitlength is not really needed, but
% you can use it for hiding ( and ) belonging to a \dimexpr
% from the scanning for a )-delimiter of a \put-command.
% You can also use eso-pic's \LenToUnit for this purpose.
% If you need to learn about length-parameters of page-layout, see the documentation of the package "layout".
\put(\ConvertToUnitlength{\dimexpr 1in+\ifodd\thepage\oddsidemargin\else\evensidemargin\fi\relax},
\ConvertToUnitlength{.5\dimexpr\paperheight-(1in+\topmargin+\headheight+\headsep+\textheight+\footskip)+\ht\strutbox\relax})%
{%
\hbox to\textwidth{\copyright\ 2022 John Doe \hfill Department of Mathematics}%
}%
\end{picture}%
%----------------------------------------------------
}%
}%
\par
\vskip 1.5em
}
\makeatother
\begin{document}
\maketitle
Text goes here\footnote{A footnote} and\footnote{Another footnote}
\lipsum[2]
\newpage
Text goes here\footnote{A footnote} and\footnote{Another footnote}
\lipsum[2]
\end{document}
答案2
或者,如果您喜歡粗俗的黑客,並且文本僅出現在標題頁上,並且標題頁在任何情況下都包含腳註,以便繪製將主文本與腳註分開的規則,那麼您就完成了標題頁通過\newpage
,您可以使用\footnotetext
right before\newpage
放置包含版權聲明的最後一個「註腳」。如果使用 hyperref,則需要將事物包裝到NoHyper
-environment 中。我不知道它如何與\raggedbottom
/相互作用\flushbottom
。
\documentclass[twoside]{article}
\usepackage{lipsum,hyperref}
\title{A sample title}
\author{John Doe}
\makeatletter
\def\@maketitle{%
\newpage
\null
\vskip 2em%
\begin{center}%
\let \footnote \thanks
{\LARGE \@title \par}%
\vskip 1.5em%
{\large
\lineskip .5em%
\begin{tabular}[t]{c}%
\@author
\end{tabular}\par}%
\vskip 1em%
{\large \@date}%
\end{center}%
% If you want this on every page, use \AddToShipoutPicture.
% If you want this on the title-page only, use \AddToShipoutPicture*.
\par
\vskip 1.5em
}
\makeatother
\begin{document}
\maketitle
Text goes here\footnote{A footnote} and\footnote{Another footnote}
\lipsum[2]
\begingroup
\makeatletter
\long\def\@makefntext#1{\noindent#1}%
\begin{NoHyper}%
\footnotetext{\par\vspace*{\dimexpr\footskip-2\baselineskip\relax}{\normalsize\copyright\ 2022 John Doe \hfill Department of Mathematics}}%
\end{NoHyper}%
\endgroup
\newpage
Text goes here\footnote{A footnote} and\footnote{Another footnote}
\lipsum[2]
\end{document}