THIS TEXT NEEDS TO BE ALIGNED
我的一页上只有文本book
,其前面带有一些vspace
值。另一页上也有一些WITH THIS TEXT
文本,其前面带有一些vspace
值、TEXT BEFORE TEXT THAT NEEDS TO BE ALIGNED
不同大小的文本和example-image-c
图像。
我需要THIS TEXT NEEDS TO BE ALIGNED
和WITH THIS TEXT
与页面顶部的距离完全相同,这样,如果两页堆叠在一起,两个文本将正确对齐。
在我当前的代码中,我分配给了ex values
文本,vspaces
甚至图像的高度。我希望通过使两个文本之前的所有元素的垂直值总数相等,我将使所需的文本正确对齐(与页面顶部的距离相同),但事实并非如此!我做错了什么?\begin{titlepage}
其中一页是否添加了一些我不知道的空间?
% !TEX TS-program = LuaLaTeX
\documentclass[11pt,twoside,openany]{book}
\pagestyle{plain}
\usepackage[english, russian]{babel}
\usepackage{fontspec}
\setmainfont{EB Garamond}[
SmallCapsFont={EB Garamond SC},
SmallCapsFeatures={Letters=SmallCaps},
Ligatures=TeX,
]
\usepackage{microtype}
\usepackage[shortcuts]{extdash}
\usepackage[pagewise]{lineno}
\usepackage[
paperwidth=6in,
paperheight=9in,
inner=15mm,
top=15mm,
outer=20mm,
bottom=22mm,
heightrounded,
]{geometry}
\usepackage{lipsum}
\setlength{\parskip}{0pt}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{titlesec}
\titleclass{\chapter}{straight}
\titleformat{\chapter}[display]{\filcenter\normalfont\large}{\thechapter.}{6pt}{}
\titlespacing*{\chapter}{0pt}{30pt}{10pt plus 10pt}
\begin{document}
\pagenumbering{gobble}
\frontmatter
% PAGE1
\vspace*{14ex}
\begin{center}
{\fontsize{4ex}{4ex}\bfseries{THIS TEXT NEEDS TO BE ALIGNED}\par} % TEXT THAT NEEDS TO BE ALIGNED
\end{center}
\vspace{9ex}
\AddToHook{shipout/background}{%
\put(0mm,-240mm){\ifnum\value{page}=0 \includegraphics[width=200mm,height=250mm,keepaspectratio]{example-image-a}\fi}
\put(60mm,-200mm){\ifnum\value{page}=0 \includegraphics[width=60mm,height=60mm,keepaspectratio]{example-image-b}\fi}
}
\clearpage
% TITLE PAGE
\begin{titlepage}
\centering
\vspace*{6ex}
{\scshape\fontsize{6ex}{6ex}{TEXT BEFORE TEXT THAT NEEDS TO BE ALIGNED}\par}
\begin{center}
\includegraphics[height=2ex,keepaspectratio]{example-image-c}
\end{center}
{\fontsize{4ex}{4ex}\bfseries{WITH THIS TEXT}\par} % TEXT THAT NEEDS TO BE ALIGNED
\vspace{9ex}
{\scshape\footnotesize{SOME RANDOM TEXT}\par}
\vspace{3ex}
{\scshape\footnotesize{SOME RANDOM TEXT}\par}
\vspace{9ex}
{\large SOME RANDOM TEXT\par}
\vspace{50ex}
{\footnotesize SOME RANDOM TEXT\par}
\vspace{0ex}
{\footnotesize SOME RANDOM TEXT\par}
\vspace{0ex}
{\footnotesize SOME RANDOM TEXT\par}
\vspace{0ex}
\vfill
\title{SOME TITLE}
\author{SOME AUTHOR}
\date{}
\end{titlepage}
\clearpage
\mainmatter
\pagenumbering{arabic}
\chapter{CHAPTER ONE}
\lipsum[1-1]
\end{document}
答案1
这种方法使用一个带有“WITH THIS TEXT”上方材料的框来计算“THIS TEXT NEEDS TO BE ALIGNED”之前所需的垂直空间,以对齐这两个句子。
( \documentclass[11pt,oneside,openany]{book}
仅用于在打开pdf文件时并排显示两页。)
更新在后续问题之后。
\documentclass[11pt,oneside,openany]{book}
\usepackage[english, russian]{babel}
\usepackage{fontspec}
\setmainfont{EB Garamond}
\usepackage{microtype}
\usepackage[shortcuts]{extdash}
\usepackage[pagewise]{lineno}
\usepackage[
paperwidth=6in,
paperheight=9in,
inner=15mm,
top=15mm,
outer=20mm,
bottom=22mm,
heightrounded,
showframe % added showframe to display the margins
]{geometry}
\usepackage{lipsum}
\setlength{\parskip}{0pt}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{titlesec}
\titleclass{\chapter}{straight}
\titleformat{\chapter}[display]{\filcenter\normalfont\large}{\thechapter.}{6pt}{}
\titlespacing*{\chapter}{0pt}{30pt}{10pt plus 10pt}
% ************************************* added <<<<<<
\newsavebox{\upperspace}
\savebox{\upperspace}{%
\begin{minipage}[b][][t]{\textwidth}
\begin{titlepage}
\centering
\vspace*{6ex}
{\scshape\fontsize{2ex}{2ex}\selectfont TEXT BEFORE TEXT THAT NEEDS TO BE ALIGNED\par}
\begin{center}
\includegraphics[height=2ex,keepaspectratio]{example-image-c}
\end{center}
\end{titlepage}
\end{minipage}
}
\newlength{\hhbox}
\settoheight{\hhbox}{\usebox{\upperspace}}
% *************************************
\begin{document}
\pagenumbering{gobble}
\frontmatter
% PAGE1
\vspace*{\dimexpr\the\hhbox-1em}% changed <<<<<<<<<
{\centering
{\fontsize{4ex}{4ex}\selectfont\bfseries THIS TEXT NEEDS TO BE ALIGNED\par}% TEXT THAT NEEDS TO BE ALIGNED
\AddToHook{shipout/background}{%
\put(0mm,-0mm){\ifnum\value{page}=0 \includegraphics[width=200mm,height=250mm,keepaspectratio]{example-image-a}\fi}
\put(60mm,-0mm){\ifnum\value{page}=0 \includegraphics[width=60mm,height=60mm,keepaspectratio]{example-image-b}\fi}
}}
\clearpage
% TITLE PAGE
\begin{titlepage}
\centering
\usebox{\upperspace}
{\fontsize{4ex}{4ex}\selectfont\bfseries WITH THIS TEXT\par} % TEXT THAT NEEDS TO BE ALIGNED
\vspace{9ex}
{\scshape\footnotesize{SOME RANDOM TEXT}\par}
\vspace{3ex}
{\scshape\footnotesize{SOME RANDOM TEXT}\par}
\vspace{9ex}
{\large SOME RANDOM TEXT\par}
\vspace{50ex}
{\footnotesize SOME RANDOM TEXT\par}
\vspace{0ex}
{\footnotesize SOME RANDOM TEXT\par}
\vspace{0ex}
{\footnotesize SOME RANDOM TEXT\par}
\vspace{0ex}
\vfill
\title{SOME TITLE}
\author{SOME AUTHOR}
\date{}
\end{titlepage}
\clearpage
\mainmatter
\pagenumbering{arabic}
\chapter{CHAPTER ONE}
\lipsum[1-1]
\end{document}
在组内使用时\fontsize{}{}\selectfont
,必须在关闭组之前结束段落。
而字体大小在发布\selectfont
新内容时baselineskip
只会在段落以\par
、 或空行结束时更新。