我正在为一所大学制作论文模板,但在设计标题页时遇到了麻烦。他们希望大学印章位于标题页上学生姓名的正后方。现在,我正在使用背景包,它允许我将背景图像放置在页面上的特定位置。但是,标题页上的学生姓名与论文标题的长度有关(IE.,如果标题较长或较短,则分别将学生姓名向下或向上移动)。有没有办法固定背景印章,使其位于学生姓名后面的中心并自动随之移动?我使用 Overleaf 作为编辑器。这是当前的 mwe:
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage[pages=some, placement=top]{background}
\newcommand{\thesistitle}{CHARACTERIZATION OF DEGRADATION IN TIN PHOSPHIDE ANODES FOR SODIUM-ION BATTERIES}
\newcommand{\studentname}{Student Name}
\newcommand{\degree}{Master of Science in Engineering}%e.g., Master of Science, Doctor of Philosphy, etc.
\newcommand{\department}{The Department of Mechanical and Aerospace Engineering}
\newcommand{\gradyear}{2022}
\newcommand{\gradmonth}{August}
\begin{document}
\backgroundsetup{contents=\includegraphics{Seal.jpg}, opacity=.3, scale=.4, angle=0, hshift=1.5cm, vshift=-4in}
\BgThispage
\newgeometry{left=1.5in,bottom=.5in}
\begin{center}
\large
\singlespacing
\textbf{\thesistitle}
\vspace{2.5cm}
\Large
\textbf{\studentname}\\
\vspace{1.5cm}
\normalsize
\textbf{A THESIS}\\
\vspace{1.5cm}
\textbf{Submitted in partial fulfillment of the requirements \\for the degree of \degree}\\
\vspace{0.1cm}
\textbf{in}\\
\vspace{0.1cm}
\textbf{\department}\\
\vspace{0.1cm}
\textbf{to}\\
\vspace{0.1cm}
\textbf{The Graduate School}\\
\vspace{0.1cm}
\textbf{of}\\
\vspace{0.1cm}
\textbf{The University of ...}\\
\vspace{0.4cm}
\textbf{\gradmonth\ \gradyear}
\end{center}
\end{document}
编译后,看起来正确无误,印章位于学生姓名正后方。参见下图。
但是,如果标题长于两行或短于两行,印章将不再以学生姓名为中心。例如:
有人能帮我吗?我知道印章背景可以手动调整。但是,模板应该会自动格式化论文,这样学生就不必自己调整格式了。
谢谢您的帮助!
答案1
你可以使用 tikzmark 库
(\AddToHookNext{shipout/background}{...}
目前还不能在 overleaf 上使用,但我听说 TL2022 将在一周左右的时间内在那里推出)
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{graphicx}
\newcommand{\thesistitle}{CHARACTERIZATION OF DEGRADATION IN TIN PHOSPHIDE ANODES FOR SODIUM-ION BATTERIES}
\newcommand{\studentname}{Student Name}
\newcommand{\degree}{Master of Science in Engineering}%e.g., Master of Science, Doctor of Philosphy, etc.
\newcommand{\department}{The Department of Mechanical and Aerospace Engineering}
\newcommand{\gradyear}{2022}
\newcommand{\gradmonth}{August}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\newgeometry{left=1.5in,bottom=.5in}
\begin{center}
\large
\singlespacing
\textbf{\thesistitle}
\vspace{2.5cm}
\Large
\textbf{\tikzmark{foo}\makebox[0pt]{studentname}}\\
\vspace{1.5cm}
\normalsize
\textbf{A THESIS}\\
\vspace{1.5cm}
\textbf{Submitted in partial fulfillment of the requirements \\for the degree of \degree}\\
\vspace{0.1cm}
\textbf{in}\\
\vspace{0.1cm}
\textbf{\department}\\
\vspace{0.1cm}
\textbf{to}\\
\vspace{0.1cm}
\textbf{The Graduate School}\\
\vspace{0.1cm}
\textbf{of}\\
\vspace{0.1cm}
\textbf{The University of ...}\\
\vspace{0.4cm}
\textbf{\gradmonth\ \gradyear}
\end{center}
\AddToHookNext{shipout/background}{
\begin{tikzpicture}[remember picture,overlay]
\node[opacity=0.2] at (pic cs:foo) {\includegraphics[width=3cm]{example-image-duck}};
\end{tikzpicture}
}
\newpage
test
\end{document}
答案2
对于 TeX 来说,将图像锚定到特定文本比锚定到背景要自然得多。只需\vbox to0pt{material\vss}
在文本前立即插入即可。您不需要任何 TikZ,只需在 中包含图形即可\vbox
。对于您的情况,插入:
\par\nointerlineskip\vbox to0pt{
\includegraphics[scale=.7]{Seal.jpg}
\vss}
就在你之前\vspace{2.5cm}
。