我在修改 veelo 章节样式时遇到了一些问题。由于我的页边距较小(我需要 A5 纸张大小),常规 veelo 无法正常工作。因此,我希望章节号与文本块右对齐(见图),而不是放在页边距中。我现在通过硬编码来实现这一点,但由于各种数字字符的宽度不同,它并不适用于所有章节。此外,超出修剪标记的黑色框与数字左对齐,导致不同章节号的框具有不同的大小。
我的问题是:您能否查看下面的代码并告诉我应该如何进行更改:1)将数字与文本块右对齐,2)使黑框具有相同的大小,而不管数字宽度是多少?
非常感谢!
\makeatletter
\newlength{\numberheight}
\setlength{\numberheight}{\beforechapskip}
\newlength{\barlength}
\makechapterstyle{myveelo}{%
\setlength{\afterchapskip}{40pt}
\renewcommand*{\chapterheadstart}{\vspace*{40pt}}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 25pt}
\renewcommand*{\chapnamefont}{\normalfont\LARGE\flushright}
\renewcommand*{\chapnumfont}{\normalfont\HUGE}
\renewcommand*{\chaptitlefont}{\normalfont\HUGE\bfseries\flushright}
\renewcommand*{\printchaptername}{%
\chapnamefont\MakeUppercase{\@chapapp}\hspace*{\midchapskip}}
\renewcommand*{\chapternamenum}{}
\setlength{\beforechapskip}{18mm}
\setlength{\midchapskip}{\paperwidth}
\addtolength{\midchapskip}{-\textwidth}
\addtolength{\midchapskip}{-\spinemargin}
\addtolength{\midchapskip}{-11.5em}
\renewcommand*{\printchapternum}{%
\makebox[0pt][l]{\hspace{-1.5cm}%
\resizebox{!}{\numberheight}{\chapnumfont \thechapter}%
\hspace{1.8em}%
\rule{\midchapskip}{\beforechapskip}%
}}%
\makeoddfoot{plain}{}{}{\thepage}}
\makeatother
答案1
你的重新定义\printchapternum
必须改为
\renewcommand*{\printchapternum}{%
\enspace\resizebox{!}{\numberheight}{\chapnumfont\thechapter}%
\rlap{\hspace{1cm}\rule{\midchapskip}{\beforechapskip}}%
}%
1cm
将用于分隔数字和填充方块的“I”更改为所需的值。
完整代码:
\documentclass{memoir}
\usepackage{graphicx}
\makeatletter
\newlength{\numberheight}
\setlength{\numberheight}{\beforechapskip}
\makechapterstyle{myveelo}{
\setlength{\afterchapskip}{40pt}
\renewcommand*{\chapterheadstart}{\vspace*{40pt}}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 25pt}
\renewcommand*{\chapnamefont}{\normalfont\LARGE\flushright}
\renewcommand*{\chapnumfont}{\normalfont\HUGE}
\renewcommand*{\chaptitlefont}{\normalfont\HUGE\bfseries\flushright}
\renewcommand*{\printchaptername}{%
\chapnamefont\MakeUppercase{\@chapapp}}
\renewcommand*{\chapternamenum}{}
\setlength{\beforechapskip}{18mm}
\setlength{\midchapskip}{\paperwidth}
\addtolength{\midchapskip}{-\textwidth}
\addtolength{\midchapskip}{-\spinemargin}
\addtolength{\midchapskip}{-11.5em}
\renewcommand*{\printchapternum}{%
\enspace\resizebox{!}{\numberheight}{\chapnumfont\thechapter}%
\rlap{\hspace{1cm}\rule{\midchapskip}{\beforechapskip}}%
}%
\makeoddfoot{plain}{}{}{\thepage}%
}
\chapterstyle{myveelo}
\makeatother
\begin{document}
\chapter{Test chapter}
\setcounter{chapter}{100}
\chapter{Test chapter}
\end{document}
输出图像: