我正在尝试根据 veelo 制作回忆录章节风格,使用以下自定义定义:
\documentclass[a5paper]{memoir}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage[showframe]{geometry}
\newlength{\numberheight}
\setlength{\numberheight}{15mm}
\makechapterstyle{myveelo}{%
\setlength{\afterchapskip}{30pt}
\renewcommand*{\chapterheadstart}{\vspace*{10pt}}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 10pt}
\renewcommand*{\chapnumfont}{\normalfont\Huge\bfseries}
\renewcommand*{\chaptitlefont}{\normalfont\Huge\bfseries}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\printchapternum}{%
\makebox[0pt][l]{%
\resizebox{!}{\numberheight}{\chapnumfont\thechapter}%
}%
\makebox[0pt][l]{%
\hspace{\textwidth}%
\hspace{1.5cm}%
\rule{2cm}{\numberheight}%
}
}%
\makeoddfoot{plain}{}{}{\thepage}
}
\chapterstyle{myveelo}
\begin{document}
\chapter{Introduction}
\lipsum[1]
\end{document}
用此制作的示例章节(使用几何包中的 showframe):
问题是数字没有对齐,并且偏移量取决于章节号(1 很大,4 小得多,等等)。有没有办法让所有章节号自动左对齐?
答案1
您可以根据首位数字应用负数字距调整。
我在边界框内仔细观察了以下值后,用肉眼计算出了它们。
\documentclass[a5paper]{memoir}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage[pass,showframe]{geometry}
\newlength{\numberheight}
\setlength{\numberheight}{15mm}
\makechapterstyle{myveelo}{%
\setlength{\afterchapskip}{30pt}
\renewcommand*{\chapterheadstart}{\vspace*{10pt}}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 10pt}
\renewcommand*{\chapnumfont}{\normalfont\Huge\bfseries}
\renewcommand*{\chaptitlefont}{\normalfont\Huge\bfseries}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\printchapternum}{%
\makebox[0pt][l]{%
\resizebox{!}{\numberheight}{\chapnumfont\fixspace{\thechapter}}%
}%
\makebox[0pt][l]{%
\hspace{\textwidth}%
\hspace{1.5cm}%
\rule{2cm}{\numberheight}%
}
}%
\makeoddfoot{plain}{}{}{\thepage}
}
\ExplSyntaxOn
\NewDocumentCommand{\fixspace}{m}
{
\martin_fixspace:e { #1 }
}
\cs_new_protected:Nn \martin_fixspace:n
{
\str_case_e:nn { \str_head:n { #1 } }
{
{0}{\kern-0.04em~}
{1}{\kern-0.08em~}
{2}{\kern-0.05em~}
{3}{\kern-0.0425em~}
{4}{\kern-0.03em~}
{5}{\kern-0.05em~}
{6}{\kern-0.045em~}
{7}{\kern-0.06em~}
{8}{\kern-0.045em~}
{9}{\kern-0.045em~}
}
#1
}
\cs_generate_variant:Nn \martin_fixspace:n { e }
\ExplSyntaxOff
\chapterstyle{myveelo}
\begin{document}
\chapter{Introduction}
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{0.1pt}
\fbox{\chapnumfont\fixspace{0}}
\fbox{\chapnumfont\fixspace{1}}
\fbox{\chapnumfont\fixspace{2}}
\fbox{\chapnumfont\fixspace{3}}
\fbox{\chapnumfont\fixspace{4}}
\fbox{\chapnumfont\fixspace{5}}
\fbox{\chapnumfont\fixspace{6}}
\fbox{\chapnumfont\fixspace{7}}
\fbox{\chapnumfont\fixspace{8}}
\fbox{\chapnumfont\fixspace{9}}
\medskip
\noindent
\fbox{\chapnumfont 0}
\fbox{\chapnumfont 1}
\fbox{\chapnumfont 2}
\fbox{\chapnumfont 3}
\fbox{\chapnumfont 4}
\fbox{\chapnumfont 5}
\fbox{\chapnumfont 6}
\fbox{\chapnumfont 7}
\fbox{\chapnumfont 8}
\fbox{\chapnumfont 9}
\lipsum[1]
\end{document}