Entfernen von zusätzlichem Platz über und unter dem Titel eines Teils

Entfernen von zusätzlichem Platz über und unter dem Titel eines Teils

Ich schreibe Vorlesungsunterlagen in LaTeX und möchte dabei einige Formatierungsrichtlinien befolgen, die im Corporate Design Guide der Universität, an der ich besuche, festgelegt sind. Insbesondere möchte ich mein Titelblatt und die Seiten, die am Anfang jeder Vorlesung eingefügt werden, so einrichten,Teilauf eine ganz bestimmte Art und Weise. Dazu verwende ich TikZ und die TikZ-Bibliothek, calcum einzelne Teile auf diesen Seiten richtig zu positionieren.

Hier ist das Problem, mit dem ich konfrontiert bin: Die Positionierung dessen, was ich % TEXTBOXim MWE unten beschriftet habe, ist relativ zur Ober-/Unterseite dessen, was ich % (SUB-)HEADLINEim MWE beschriftet habe. Auf meiner Titelseite funktioniert das einwandfrei. Damit meine ich, dass das Feld, das den Text in den % (SUB-)HEADLINEKomponenten umschließt, direkt über und unter dem eigentlichen Text beginnt und endet. Für die Seiten, die durch den \part{...}Befehl am Anfang jedes Teils eingeführt werden, scheint jedoch über und unter dem Text im % HEADLINETeil der Seite zusätzlicher Platz zu sein. Dieser Platz ändert sich, wenn ich das zweite Argument des \fontsize{}{}Befehls manipuliere, und das Verhalten ist unterschiedlich, je nachdem, ob der Teiltitel eine oder zwei Zeilen umfasst (wie im MWE gezeigt). Beachten Sie, dass die im \fontsizeBefehl gewählten Werte nicht willkürlich sind, sondern in der Stilrichtlinie festgelegt sind, die ich befolgen möchte. Daher würde ich diese, wenn möglich, lieber nicht ändern.

Ich habe ziemlich viel Zeit damit verbracht, eine Antwort auf dieses Problem zu finden und bin auf die folgenden Befehle gestoßen:

  • partheadstartvskip
  • partheadendvskip
  • RedeclareSectionCommand[...]{part}zusammen mit den Optionen/Parametern beforeskip, afterskip,innerskip

Allerdings ist es mir damit nicht gelungen, den zusätzlichen Platz auf demTeilSeiten, die auf meiner Titelseite nicht vorhanden sind.

Wir sind für jede Hilfe sehr dankbar!

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

Antwort1

Wenn Sie für die Titelseite und die Teiletitel die gleiche Formatierung wünschen, würde ich vorschlagen, für beide den gleichen Code zu verwenden:

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

Hier sind die Ergebnisse nur der ungeraden Seiten:

Beispiel ohne Strebe

Ich habe \let\strut\relaxdiese Lösung hinzugefügt, weil KOMA-Script immer ein \strutan das Ende des Textes der Teilüberschrift anfügt, um die gleiche Höhe und Tiefe von z. B. „ace“ und „ACÉ (generisch)“ zu haben, aber es scheint, dass Sie dies nicht wollen. Wenn Sie möchten, können Sie alternativ das entfernen und ein und an das Ende der Argumente auf Ihrer Titelseite \let\strut\relaxhinzufügen :\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}

mit Strebe

In beiden Fällen sind die einzigen Unterschiede zwischen der Titelseite und den Teilseiten die Höhe und Tiefe des Untertitels, da im Untertitel der Titelseite ein y, |, und steht. Um diesen Unterschied zu vermeiden, können Sie die Verwendung des Untertitels ergänzen:/\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}

mit extra Strebe für den Untertitel

Übrigens: Theoretisch würde KOMA-Script auch die Definition eines völlig neuen Abschnittsstils unterstützen. Leider gibt es derzeit keine offizielle Dokumentation dieser Funktion, vielleicht weil derzeit ein interner Befehl definiert werden muss:

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

Hinweis: Dies ist ein sehr rudimentäres Beispiel. Es unterstützt beispielsweise nicht das erweiterte optionale Argument des originalen KOMA-Scripts \part. Es zeigt jedoch, dass die Definition neuer Schnittstile sehr einfach sein kann.

verwandte Informationen