Deshacerse del espacio adicional encima y debajo del título de una parte

Deshacerse del espacio adicional encima y debajo del título de una parte

Estoy escribiendo notas de conferencias en LaTeX y quiero seguir algunas pautas de formato establecidas en la Guía de diseño corporativo de la universidad a la que asisto. En particular, quiero configurar mi página de título y las páginas insertadas al principio de cadapartede una manera muy específica. Para hacerlo, estoy usando TikZ y la biblioteca TikZ calcpara colocar correctamente partes individuales en estas páginas.

Este es el problema al que me enfrento: la posición de lo que he etiquetado % TEXTBOXen el MWE a continuación es relativa a la parte superior/inferior de lo que he etiquetado % (SUB-)HEADLINEen el MWE. En mi portada, esto funciona perfectamente bien. Con esto quiero decir que el cuadro que encierra el texto en los % (SUB-)HEADLINEcomponentes comienza y termina directamente encima y debajo del texto real. Sin embargo, para las páginas introducidas por el \part{...}comando al principio de cada parte, parece haber espacio adicional encima y debajo del texto en la % HEADLINEparte de la página. Esta cantidad de espacio cambia a medida que manipulo el segundo argumento del \fontsize{}{}comando, y el comportamiento es diferente dependiendo de si el título de la parte abarca una o dos líneas (como se muestra en el MWE). Tenga en cuenta que los valores elegidos en el \fontsizecomando no son arbitrarios, sino que están fijados en la guía de estilo que pretendo seguir. Por lo tanto, preferiría no cambiarlos, si es posible.

Pasé bastante tiempo tratando de encontrar una respuesta a este problema y encontré los siguientes comandos:

  • partheadstartvskip
  • partheadendvskip
  • RedeclareSectionCommand[...]{part}junto con las opciones/parámetros beforeskip, afterskip,innerskip

Sin embargo, al usarlos, no he podido deshacerme del espacio adicional en elpartepáginas que no están presentes en mi portada.

¡Cualquier ayuda con esto es muy 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}

Respuesta1

Si desea el mismo formato para la página de título y los títulos de las partes, le sugeriría utilizar el mismo 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}

Aquí están los resultados sólo las páginas impares:

ejemplo sin puntal

He agregado \let\strut\relaxa esta solución, porque KOMA-Script siempre agrega un \strutal final del texto del encabezado de la parte, para tener la misma altura y profundidad de, por ejemplo, "ace" y "ACÉ (genérico)", pero Parece que no quieres esto. Pero si lo desea, también puede eliminar \let\strut\relaxy agregar un \struty el final de los argumentos en su 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}

con puntal

En ambos casos las únicas diferencias entre la página de título y las páginas parciales son la altura y la profundidad del subtítulo, debido a un y, |y /en el subtítulo de la página de título. Para evitar esta diferencia, puedes agregar \strutal uso del subtí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\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}

con puntal extra para el subtítulo

Por cierto: en teoría, KOMA-Script también permitiría definir un estilo de sección completamente nuevo. Desafortunadamente actualmente no existe una documentación oficial de esta característica, tal vez porque actualmente necesita definir un 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 es un ejemplo muy rudimentario. Por ejemplo, no admite el argumento opcional extendido del KOMA-Script original \part. Sin embargo, muestra que la definición de nuevos estilos de sección podría ser muy fácil.

información relacionada