
Há apenas THIS TEXT NEEDS TO BE ALIGNED
texto em uma página minha book
precedida por algum vspace
valor. Há também algum WITH THIS TEXT
texto em outra página precedido por algum vspace
valor, TEXT BEFORE TEXT THAT NEEDS TO BE ALIGNED
texto de tamanho diferente e uma example-image-c
imagem.
Eu preciso THIS TEXT NEEDS TO BE ALIGNED
e WITH THIS TEXT
estar exatamente à mesma distância do topo da página para que, se as duas páginas estiverem empilhadas juntas, os dois textos fiquem devidamente alinhados entre si.
No meu código atual atribuí ex values
aos textos vspaces
e até à altura da imagem. Eu esperava que, ao igualar o número total de valores verticais de todos os elementos que precedem os dois textos, eu tivesse os textos necessários devidamente alinhados (à mesma distância do topo da página), mas não estão! O que estou fazendo de errado? Em uma das páginas adiciona \begin{titlepage}
algum espaço que não conheço?
% !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}
Responder1
Esta abordagem utiliza uma caixa com o material acima “COM ESTE TEXTO” para calcular o espaço vertical necessário antes de “ESTE TEXTO PRECISA SER ALINHADO” para alinhar as duas frases.
(Usando \documentclass[11pt,oneside,openany]{book}
apenas para exibir as duas páginas lado a lado ao abrir o arquivo pdf.)
ATUALIZADAapós perguntas de acompanhamento.
\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}
Ao utilizar \fontsize{}{}\selectfont
dentro de um grupo, é necessário finalizar o parágrafo antes de fechar o grupo.
Enquanto o tamanho da fonte é atualizado ao emitir \selectfont
o novo, baselineskip
ele só é atualizado quando o parágrafo termina usando \par
, ou por uma linha em branco.