パーツのタイトルの上下の余分なスペースを削除する

パーツのタイトルの上下の余分なスペースを削除する

私はLaTeXで講義ノートを書いていますが、通っている大学の企業デザインガイドに記載されている書式設定のガイドラインに従いたいと思っています。特に、タイトルページと各ページの冒頭に挿入するページを設定したいと考えています。一部非常に具体的な方法で。そのために、私は TikZ と TikZ ライブラリを使用して、calcこれらのページ上の個々のパーツを正しく配置しています。

% TEXTBOX私が直面している問題は次のとおりです。以下の MWE でラベル付けしたものの位置は、% (SUB-)HEADLINEMWE でラベル付けしたものの上部/下部を基準にしています。タイトル ページでは、これは完全に正常に機能します。つまり、コンポーネント内のテキストを囲むボックスは、実際のテキストの真上と真下で始まり、真下で終わります。ただし、各パートの先頭のコマンド% (SUB-)HEADLINEによって導入されるページの場合、ページの一部でテキストの上下に追加のスペースがあるようです。このスペースの量は、コマンドの 2 番目の引数を操作すると変化し、パート タイトルが 1 行にまたがるか 2 行にまたがるか (MWE に示されているように) によって動作が異なります。コマンドで選択された値は任意ではなく、従う予定のスタイル ガイドラインで固定されていることに注意してください。したがって、可能であれば、これらの値は変更しないことをお勧めします。\part{...}% HEADLINE\fontsize{}{}\fontsize

私はこの問題の答えを見つけるのにかなりの時間を費やし、次のコマンドに出会いました。

  • partheadstartvskip
  • partheadendvskip
  • RedeclareSectionCommand[...]{part}オプション/パラメータとともにbeforeskip、、afterskipinnerskip

しかし、これらを使用しても、一部タイトル ページに存在しないページ。

これに関してのご協力は大歓迎です!

\documentclass[paper=a4, fontsize=11pt]{scrbook}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{setspace}

% MODIFY APPEARANCE OF PART PAGES
\renewcommand\partformat{%
    \fontsize{12pt}{14pt}\selectfont%
    \partname~\thepart%
}

\setkomafont{part}{\fontsize{24pt}{34pt}\selectfont}

\renewcommand\partlineswithprefixformat[3]{%
    \thispagestyle{empty}%
    \begin{tikzpicture}[remember picture, overlay]
        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (headline) at ($(current page.south west) + (16mm, 72mm)$) {#3};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (subheadline) at ($(headline.north west) + (0, 16mm)$) {#2};

         % BACKGROUND
        \fill[lightgray] ($(current page.north west) + (8mm, -38mm)$) rectangle ($(current page.east |- subheadline.north) + (0, 16mm)$);

        % TEXTBOX
        \fill[gray, fill opacity=0.9] ($(current page.west |- subheadline.north) + (0mm, 32mm)$) rectangle ($(current page.west |- headline.south) + (154mm, -16mm)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (headline.south west) {#3};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (subheadline.south west) {#2};
    \end{tikzpicture}
}


\begin{document}
\sffamily
\onehalfspacing

% TITLE PAGE
\begin{titlepage}
    \begin{tikzpicture}[remember picture, overlay]
        % BACKGROUND
        \fill[lightgray] ($(current page.north west) + (8mm, -38mm)$) rectangle ($(current page.south east)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (headline) at ($(current page.south west) + (16mm, 32mm)$) {\fontsize{24pt}{34pt}\selectfont \sffamily\bfseries Quantitative Foundations of \\ Artificial Intelligence \par};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (subheadline) at ($(headline.north west) + (0, 8mm)$) {\fontsize{12pt}{14pt}\selectfont \sffamily\bfseries Name of University \textbar{} Winter 2023/24 \par};

        % TEXTBOX
        \fill[gray, fill opacity=0.9] ($(current page.west |- subheadline.north) + (0mm, 16mm)$) rectangle ($(current page.south west) + (154mm, 16mm)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (headline.south west) {\fontsize{24pt}{34pt}\selectfont \bfseries Quantitative Foundations of \\ Artificial Intelligence \par};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (subheadline.south west) {\fontsize{12pt}{14pt}\selectfont \bfseries Name of University \textbar{} Winter 2023/24 \par};
    \end{tikzpicture}
\end{titlepage}

\part{Quantitative Foundations of Artificial Intelligence}
\part{Quantitative Foundations}

\end{document}

答え1

タイトル ページとパート タイトルに同じ書式を設定する場合は、両方に同じコードを使用することをお勧めします。

\documentclass[paper=a4, fontsize=11pt]{scrbook}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{setspace}

% MODIFY APPEARANCE OF PART PAGES
\renewcommand\partformat{%
    \partname~\thepart%
}

% You can do the font selection in the TikZ code below,
% and then either don't change the fontsize here (or
% use \normalsize) would be enough.
\setkomafont{part}{}
\setkomafont{partnumber}{}
% You also do all the distances in the TikZ code, so
% not adding additional distances by the part heading itself
% would be suggested.
\RedeclareSectionCommand[beforeskip=0pt,innerskip=0pt,afterskip=0pt]{part}

\newcommand{\TikZTitle}[2]{%
    \begin{tikzpicture}[remember picture, overlay]
        % BACKGROUND
        \fill[lightgray] ($(current page.north west) + (8mm, -38mm)$) rectangle ($(current page.south east)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (headline) at ($(current page.south west) + (16mm, 32mm)$) {\fontsize{24pt}{34pt}\let\strut\relax\sffamily\bfseries #2\par};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (subheadline) at ($(headline.north west) + (0, 8mm)$) {\fontsize{12pt}{14pt}\sffamily\bfseries #1\par};

        % TEXTBOX
        \fill[gray, fill opacity=0.9] ($(current page.west |- subheadline.north) + (0mm, 16mm)$) rectangle ($(current page.south west) + (154mm, 16mm)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (headline.south west) {\fontsize{24pt}{34pt}\bfseries\let\strut\relax #2\par};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (subheadline.south west) {\fontsize{12pt}{14pt}\bfseries #1\par};
   \end{tikzpicture}
}

\renewcommand\partlineswithprefixformat[3]{%
  \thispagestyle{empty}%
  \TikZTitle{#2}{#3}%
}


\begin{document}
\sffamily
\onehalfspacing

% TITLE PAGE
\begin{titlepage}
  \TikZTitle{Name of University \textbar{} Winter 2023/24}
            {Quantitative Foundations of \\ Artificial Intelligence }
\end{titlepage}

\part[{Quantitative Foundations of Artificial Intelligence}]{Quantitative Foundations of \\ Artificial Intelligence}
\part{Quantitative Foundations}

\end{document}

奇数ページのみの結果は次のとおりです。

ストラットなしの例

\let\strut\relaxKOMA-Script は、常に\strutパーツ見出しのテキストの末尾に を追加して、たとえば「ace」と「ACÉ (generic)」の高さと深さを同じにするため、このソリューションに追加しましたが、どうやらこれは望ましくないようです。ただし、必要な場合は、 を削除し、タイトル ページの引数の末尾に\let\strut\relaxを追加することもできます。\strut

\documentclass[paper=a4, fontsize=11pt]{scrbook}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{setspace}

% MODIFY APPEARANCE OF PART PAGES
\renewcommand\partformat{%
    \partname~\thepart%
}

% You can do the font selection in the TikZ code below,
% and then either don't change the fontsize here (or
% use \normalsize) would be enough.
\setkomafont{part}{}
\setkomafont{partnumber}{}
% You also do all the distances in the TikZ code, so
% not adding additional distances by the part heading itself
% would be suggested.
\RedeclareSectionCommand[beforeskip=0pt,innerskip=0pt,afterskip=0pt]{part}

\newcommand{\TikZTitle}[2]{%
    \begin{tikzpicture}[remember picture, overlay]
        % BACKGROUND
        \fill[lightgray] ($(current page.north west) + (8mm, -38mm)$) rectangle ($(current page.south east)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (headline) at ($(current page.south west) + (16mm, 32mm)$) {\fontsize{24pt}{34pt}\sffamily\bfseries #2\par};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (subheadline) at ($(headline.north west) + (0, 8mm)$) {\fontsize{12pt}{14pt}\sffamily\bfseries #1\par};

        % TEXTBOX
        \fill[gray, fill opacity=0.9] ($(current page.west |- subheadline.north) + (0mm, 16mm)$) rectangle ($(current page.south west) + (154mm, 16mm)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (headline.south west) {\fontsize{24pt}{34pt}\bfseries #2\par};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (subheadline.south west) {\fontsize{12pt}{14pt}\bfseries #1\par};
   \end{tikzpicture}
}

\renewcommand\partlineswithprefixformat[3]{%
  \thispagestyle{empty}%
  \TikZTitle{#2}{#3}%
}


\begin{document}
\sffamily
\onehalfspacing

% TITLE PAGE
\begin{titlepage}
  \TikZTitle{Name of University \textbar{} Winter 2023/24}
            {Quantitative Foundations of \\ Artificial Intelligence\strut}
\end{titlepage}

\part[{Quantitative Foundations of Artificial Intelligence}]
{Quantitative Foundations of \\ Artificial Intelligence}
\part{Quantitative Foundations}

\end{document}

ストラット付き

どちらの場合も、タイトル ページとパート ページの違いは、タイトル ページのサブタイトルに 、 、 があるため、サブタイトルの高さと深さのみです。yこの違いを回避するには、サブタイトルの使用法に を追加します。|/\strut

\documentclass[paper=a4, fontsize=11pt]{scrbook}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{setspace}

% MODIFY APPEARANCE OF PART PAGES
\renewcommand\partformat{%
    \partname~\thepart%
}

% You can do the font selection in the TikZ code below,
% and then either don't change the fontsize here (or
% use \normalsize) would be enough.
\setkomafont{part}{}
\setkomafont{partnumber}{}
% You also do all the distances in the TikZ code, so
% not adding additional distances by the part heading itself
% would be suggested.
\RedeclareSectionCommand[beforeskip=0pt,innerskip=0pt,afterskip=0pt]{part}

\newcommand{\TikZTitle}[2]{%
    \begin{tikzpicture}[remember picture, overlay]
        % BACKGROUND
        \fill[lightgray] ($(current page.north west) + (8mm, -38mm)$) rectangle ($(current page.south east)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (headline) at ($(current page.south west) + (16mm, 32mm)$) {\fontsize{24pt}{34pt}\sffamily\bfseries #2\par};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (subheadline) at ($(headline.north west) + (0, 8mm)$) {\fontsize{12pt}{14pt}\sffamily\bfseries\strut #1\par};

        % TEXTBOX
        \fill[gray, fill opacity=0.9] ($(current page.west |- subheadline.north) + (0mm, 16mm)$) rectangle ($(current page.south west) + (154mm, 16mm)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (headline.south west) {\fontsize{24pt}{34pt}\bfseries #2\par};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (subheadline.south west) {\fontsize{12pt}{14pt}\bfseries\strut #1\par};
   \end{tikzpicture}
}

\renewcommand\partlineswithprefixformat[3]{%
  \thispagestyle{empty}%
  \TikZTitle{#2}{#3}%
}


\begin{document}
\sffamily
\onehalfspacing

% TITLE PAGE
\begin{titlepage}
  \TikZTitle{Name of University \textbar{} Winter 2023/24}
            {Quantitative Foundations of \\ Artificial Intelligence\strut}
\end{titlepage}

\part[{Quantitative Foundations of Artificial Intelligence}]
{Quantitative Foundations of \\ Artificial Intelligence}
\part{Quantitative Foundations}

\end{document}

字幕用の追加の支柱付き

ところで、理論的には、KOMA スクリプトは完全に新しいセクション スタイルの定義もサポートします。残念ながら、現時点ではこの機能の公式ドキュメントはありません。おそらく、現在は内部コマンドを定義する必要があるためです。

\documentclass[paper=a4, fontsize=11pt]{scrbook}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{setspace}

% MODIFY APPEARANCE OF PART PAGES
\renewcommand\partformat{%
    \partname~\thepart%
}

\newcommand{\TikZTitle}[2]{%
    \begin{tikzpicture}[remember picture, overlay]
        % BACKGROUND
        \fill[lightgray] ($(current page.north west) + (8mm, -38mm)$) rectangle ($(current page.south east)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (headline) at ($(current page.south west) + (16mm, 32mm)$) {\fontsize{24pt}{34pt}\sffamily\bfseries #2\par};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm,
        text=white] (subheadline) at ($(headline.north west) + (0, 8mm)$)
        {\fontsize{12pt}{14pt}\sffamily\bfseries #1\par};

        % TEXTBOX
        \fill[gray, fill opacity=0.9] ($(current page.west |- subheadline.north) + (0mm, 16mm)$) rectangle ($(current page.south west) + (154mm, 16mm)$);

        % HEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (headline.south west) {\fontsize{24pt}{34pt}\bfseries #2\par};

        % SUBHEADLINE
        \node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white, draw] at (subheadline.south west) {\fontsize{12pt}{14pt}\bfseries #1\par};
   \end{tikzpicture}
}

\makeatletter
% This is used to set the style tikzpart of a command. The argument is the
% name of the command as used for \DeclareSectionCommand etc.
\newcommand*{\scr@dsc@def@style@tikzpart@command}[1]{%
  \@namedef{#1}{\dotikzpart{#1}}%
}
% This makes a new heading of type tikzpart. The aruments are:
% #1: The name of the command (see \scr@dsc@def@style@tikzpart@command)
% #2: star or not (star is used for not numbered headings)
% #3: ToC entry (currently only used for numbered headings)
% #4: title
\NewDocumentCommand\dotikzpart{m s O{#4} m}
  {
    \cleardoubleoddpage\thispagestyle{empty}%
    \IfBooleanTF{#2}{%
      \TikZTitle{}{#4}%
    }{%
      \refstepcounter{#1}%
      \@nameuse{add#1tocentry}{\@nameuse{the#1}}{#3}%
      \TikZTitle{\csname #1format\endcsname}{#4}%
    }%
    \clearpage
  }
\makeatother
\RedeclareSectionCommand[style=tikzpart]{part}% use the new style for \part 

\begin{document}
\sffamily
\onehalfspacing

\tableofcontents

% TITLE PAGE
\begin{titlepage}
  \TikZTitle{Name of University \textbar{} Winter 2023/24}
            {Quantitative Foundations of \\ Artificial Intelligence}
\end{titlepage}

\part[{Quantitative Foundations of Artificial Intelligence}]
{Quantitative Foundations of \\ Artificial Intelligence}
\part{Quantitative Foundations}

\end{document}

注: これは非常に基本的な例です。たとえば、元の KOMA スクリプトの拡張オプション引数はサポートされていません\part。ただし、新しいセクション スタイルの定義が非常に簡単であることを示しています。

関連情報