異なるサイズのテキストや画像が混在している場合、異なるページの同じサイズのテキストがページ上部から同じ距離にあることを確認する方法

異なるサイズのテキストや画像が混在している場合、異なるページの同じサイズのテキストがページ上部から同じ距離にあることを確認する方法

THIS TEXT NEEDS TO BE ALIGNED私のページの 1 つには、book何らかの値が先行するテキストだけがありますvspaceWITH THIS TEXT別のページにも、何らかのvspace値が先行するテキスト、TEXT BEFORE TEXT THAT NEEDS TO BE ALIGNED異なるサイズのテキスト、およびexample-image-c画像があります。両方のページを重ねた場合に両方のテキストが互いに適切に配置されるように、ページの上部から と が正確に同じ距離にある必要があります。現在
の コードでは、テキストに を割り当て、さらに画像の高さにも を割り当てています。両方のテキストの前にあるすべての要素の垂直値の合計数を等しくすることで、必要なテキストが適切に配置される (ページの上部から同じ距離に) ことを期待していましたが、そうではありません。何が間違っているのでしょうか。ページの 1 つで、私が気付いていないスペースが追加されているのでしょうか。THIS TEXT NEEDS TO BE ALIGNEDWITH THIS TEXT
ex valuesvspaces\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」の前に必要な垂直スペースを計算し、2 つの文を揃えます。

c

( \documentclass[11pt,oneside,openany]{book}PDF ファイルを開いたときに 2 つのページを並べて表示する場合にのみ使用します。)

更新しましたフォローアップの質問の後。

\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か、空白行で終了した場合にのみ更新されます。

見る\fontsize{}{} はどのように機能しますか?

関連情報