Livrar-se do espaço adicional acima e abaixo do título de uma parte

Livrar-se do espaço adicional acima e abaixo do título de uma parte

Estou escrevendo notas de aula em LaTeX e quero seguir algumas diretrizes de formatação estabelecidas no Guia de Design Corporativo da universidade que estou cursando. Em particular, quero configurar minha página de título e as páginas inseridas no início de cadapapelde uma forma muito específica. Para fazer isso, estou usando o TikZ e a biblioteca TikZ calcpara posicionar corretamente as partes individuais nessas páginas.

Aqui está o problema que estou enfrentando: o posicionamento do que rotulei % TEXTBOXno MWE abaixo é relativo à parte superior/inferior do que rotulei % (SUB-)HEADLINEno MWE. Na minha página de título, isso funciona perfeitamente bem. Com isso quero dizer que a caixa que encerra o texto nos % (SUB-)HEADLINEcomponentes começa e termina diretamente acima e abaixo do texto real. Porém, para as páginas introduzidas pelo \part{...}comando no início de cada parte, parece haver espaço adicional acima e abaixo do texto na % HEADLINEparte da página. Essa quantidade de espaço muda conforme eu manipulo o segundo argumento do \fontsize{}{}comando, e o comportamento é diferente dependendo se o título da parte abrange uma ou duas linhas (conforme mostrado no MWE). Observe que os valores escolhidos no \fontsizecomando não são arbitrários, mas estão fixados na diretriz de estilo que pretendo seguir. Portanto, prefiro não alterá-los, se possível.

Passei bastante tempo tentando encontrar uma resposta para esse problema e me deparei com os seguintes comandos:

  • partheadstartvskip
  • partheadendvskip
  • RedeclareSectionCommand[...]{part}junto com as opções/parâmetros beforeskip, afterskip,innerskip

No entanto, usando-os, não consegui me livrar do espaço adicional nopapelpáginas que não estão presentes na minha página de título.

Qualquer ajuda sobre isso é muito apreciada!

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

Responder1

Se você quiser a mesma formatação para a página de título e os títulos das partes, sugiro usar o mesmo código para ambos:

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

Aqui estão os resultados apenas nas páginas ímpares:

exemplo sem suporte

Eu adicionei \let\strut\relaxa esta solução, porque o KOMA-Script sempre adiciona um \strutao final do texto do cabeçalho da parte, para ter a mesma altura e profundidade de, por exemplo, “ace” e “ACÉ (genérico)”, mas parece que você não quer isso. Mas se quiser, você pode alternativamente remover \let\strut\relaxe adicionar um \strute o final dos argumentos na sua página de título:

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

com suporte

Em ambos os casos, as únicas diferenças entre a página de título e as páginas parciais são a altura e a profundidade do subtítulo, por causa de um y, |e /no subtítulo da página de título. Para evitar essa diferença, você pode adicionar \strutao uso da legenda:

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

com suporte extra para a legenda

BTW: Teoricamente, o KOMA-Script também ajudaria a definir um estilo de corte completamente novo. Infelizmente atualmente não existe uma documentação oficial deste recurso, talvez porque atualmente seja necessário definir um comando interno:

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

Nota: Este é um exemplo muito rudimentar. Por exemplo, não suporta o argumento opcional estendido do KOMA-Script original \part. Contudo, mostra que a definição de novos estilos de seccionamento pode ser muito fácil.

informação relacionada