我正在尝试根据报告文档类排版一份精美的传单。文档中的章节名称使用 Scriptina 字体 (TTF) 排版 (字体链接),其余部分采用 Comfortaa 字体(字体链接)。
问题是字母 l、b 和 d 很高,而字母 g 则在 Scriptina 字体中显得很低(我不知道这种字体的技术名称)。这会导致章节名称的位置不同,具体取决于其中是否有 l、b 或 d 字母。下图显示了效果。
如图所示,当章节名称包含提到的字母时,其垂直轴上的偏移量相当大。
我的问题是:如何根据章节数量的高度而不是最高字母的高度来放置章节名称?换句话说,是否可以将所有章节名称放在垂直轴上的同一位置?章节名称上方的空间应足以容纳长字母而不会与顶部边框相撞。
MWE 如下所示。
\documentclass[a5paper,10pt,openany]{report}
\usepackage[object=vectorian]{pgfornament}
\usetikzlibrary{positioning,calc}
\usepackage{fontspec}
\usepackage[left=2cm,right=2cm, top=1cm]{geometry}
\usepackage[spanish,german]{babel}
\usepackage{titlesec}
%Par
\setlength{\parindent}{0pt}
%Chapter format
\titleformat{\chapter}[display]
{}
{\pageframe }
{0ex}
{\vspace*{-10ex}\setmainfont{Scriptina}
\fontsize{35}{\baselineskip}\selectfont \thechapter{} }
[]
%Page numbering font
\renewcommand{\thepage}{\setmainfont{Comfortaa}\fontsize{8}{\baselineskip}\selectfont\bfseries\arabic{page}}
%Counters for numbering
\setcounter{tocdepth}{0}
\setcounter{chapter}{0}
%Table of contents on the titlepage
\makeatletter
\newcommand*{\toccontents}{\@starttoc{toc}}
\makeatother
%author, date and title.
\title{}
\author{}
\date{\vspace{-5ex}}
%Offsets of the frame, number of the ornaments and color
\def\xoffset{0.6cm}
\def\yoffset{0.6cm}
\def\ornament{61}
\def\ornamentcolor{black}
%Command for inserting the frames
\newcommand{\pageframe}{
\begin{tikzpicture}[remember picture, overlay, inner sep=0pt]
%Necessary coordinates
\coordinate (UR) at ($(current page.north east) + (-\xoffset,-\yoffset)$);
\coordinate (UL) at ($(current page.north west) + (\xoffset,-\yoffset)$);
\coordinate (LR) at ($(current page.south east) + (-\xoffset,\yoffset)$);
\coordinate (LL) at ($(current page.south west) + (\xoffset,\yoffset)$);
\coordinate (CL) at ($(current page.west) + (\xoffset,0)$);
\coordinate (CR) at ($(current page.east) + (-\xoffset,0)$);
%Ornaments located at the corners of the page
\node[anchor=north west] (ULCorner) at (UL){%
\pgfornament[width = 2cm,color = \ornamentcolor ]{\ornament}};%
\node[anchor=north east] (URCorner) at (UR){%
\pgfornament[width = 2cm,color = \ornamentcolor, symmetry=v ]{\ornament}};%
\node[anchor=south east] (LRCorner) at (LR){%
\pgfornament[width = 2cm,color = \ornamentcolor, symmetry=c ]{\ornament}};%
\node[anchor=south west] (LLCorner) at (LL){%
\pgfornament[width = 2cm,color = \ornamentcolor, symmetry=h ]{\ornament}};%
%Ornaments between the corners: Calculates the distance between the 2 upper corners and uses it for the width of the bar ornament.
\path (CL) let \p1 = ($(URCorner.north west) - (ULCorner.north east)$)
in node[anchor=center, rotate=90, inner sep=-3pt] (CLBar) at (CL){\pgfornament[width=\x1 ,color = \ornamentcolor]{88}};%
\path (CR) let \p1 = ($(URCorner.north west) - (ULCorner.north east)$)
in node[anchor=center, rotate=90, inner sep=0pt] (CRBar) at (CR){\pgfornament[width=\x1 ,color = \ornamentcolor]{88}};%
\draw[line width=1.5pt,line cap=round]($(CLBar.east) + (0.8pt,0)$) to ($(ULCorner.south west) + (0.8pt,1pt)$){};
\draw[line width=1.5pt,line cap=round]($(CRBar.east) + (0.8pt,-1pt)$) to ($(URCorner.south east) + (0.8pt,1pt)$){};
\draw[line width=1.5pt,line cap=round]($(CLBar.west) + (0.8pt,0)$) to ($(LLCorner.north west) + (0.8pt,-1pt)$){};
\draw[line width=1.5pt,line cap=round]($(CRBar.west) + (0.8pt,1)$) to ($(LRCorner.north east) + (0.8pt,-1pt)$){};
%Ornaments between he corners: Top and bottom.
\path (ULCorner.north east) to [ornament=88] (URCorner.north west) {};
\path (LRCorner.south west) to [ornament=88] (LLCorner.south east) {};
\end{tikzpicture}}
\begin{document}
\begin{titlepage}
\pageframe
\setmainfont{Scriptina}
\begin{center}
{\fontsize{60}{\baselineskip}\selectfont Lorem \\[\baselineskip]
a\\[\baselineskip]
Ipsum}
\end{center}
\vspace{4\baselineskip}
\fontsize{35}{\baselineskip}\selectfont
Dolor
\fontsize{12}{\baselineskip}\selectfont
\setmainfont{Comfortaa}
\toccontents
\clearpage\cleardoublepage
\end{titlepage}
\maketitle
\chapter{A b c d t l}
\chapter{E m r g}
\chapter{aconme}
\chapter{}
\end{document}