修改後的 veelo 章節樣式的對齊(回憶錄)

修改後的 veelo 章節樣式的對齊(回憶錄)

我在修改 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}

輸出影像:

在此輸入影像描述

相關內容