我想为模板封面创建一个新命令,我认为特定类型的格式看起来很棒,但我无法实现它。本质上,我想要做的是让标题有两行,每行的文本应该具有相同的长度,但字体大小不同,例如: 但是,我无法创建一个优化此过程的命令。手动执行此操作很简单,但不断更改尺寸并不是最有效的方法。到目前为止,我想到的是以下内容:
.cls 文件
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{igclass}[2023/10/10 Custom template]
\LoadClass[a4paper, twoside, 11pt]{book}
\RequirePackage[english]{babel}
\RequirePackage[utf8]{inputenc}
\RequirePackage[default,oldstyle,scale=0.95]{opensans}
\RequirePackage[T1]{fontenc}
\RequirePackage{csquotes}
\RequirePackage{calc}
\RequirePackage{xcolor}
\RequirePackage{tikz}
\RequirePackage{pgfplots}
\RequirePackage[top = 2.5cm,
bottom = 3.8cm,
left = 2cm,
right = 2cm,
]{geometry}
\RequirePackage{fancyhdr}
\RequirePackage{etoolbox}
\RequirePackage{lmodern}
\RequirePackage{titlesec}
\usetikzlibrary{tikzmark, calc}
\pgfplotsset{compat=1.18}
\definecolor{myDColor}{HTML}{101010}
\definecolor{myLColor}{HTML}{7736d9}
\newcommand{\pretitle}[2]{%
\begin{titlepage}
\pagestyle{empty}
\newlenght{\longest}
\newcommand{\texta}{#1}
\newcommand{\textb}{#2}
\ifthenelse{\lengthtest{{\widthof{\texta}}>{\widthof{\textb}}}}
{
\setlength{\longest}{\widthof{\texta}}
}
{
\setlength{\longest}{\widthof{\textb}}
}
\begin{tikzpicture}[remember picture,overlay]
% BACKGROUND
\fill[white] (current page.south west) rectangle (current page.north east);
\node[%
myDColor,
rounded corners,
minimum height = 3cm,
minimum width = 0.625*\paperwidth,
right,
] (title) at ($(current page.west)+(1,2)$){%
{\fontsize{45}{60} \selectfont \bfseries \MakeUppercase{
\parbox{\widthof{#1}}{
#1\\
#2
}
}
}
};
\end{tikzpicture}
\end{titlepage}
}
.tex 文件
\documentclass{igclass}
\pagestyle{plain}
\begin{document}
\pretitle{A long text for title}{and a small}
\end{document}