修正された 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数字と塗りつぶされた四角を区切るために使用した値を希望の値に変更します。

完全なコード:

\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}

出力の画像:

ここに画像の説明を入力してください

関連情報