Suprimir a página de título da "parte" no scrbook KOMA

Suprimir a página de título da "parte" no scrbook KOMA

Estou trabalhando na composição de um livro que tem uma linda arte para os títulos dos capítulos, além de arte de página inteira para cada parte (para que a Parte 1 obtenha uma arte que incorpore o texto "Parte 1", etc.). Suprimi com sucesso o título do capítulo com:

\newcommand{\mychapter}[1]{%
  \begingroup
  \let\@makechapterhead\@gobble % make \@makechapterhead do nothing
  \chapter{#1}
  \endgroup
}

(Isso funciona, mas Koma reclama da redefinição de @makechapterhead. Estou bem com isso por enquanto, mas idealmente gostaria de uma solução que não incomodasse Koma.)

No entanto, gostaria de fazer o mesmo com \part e também com \chapter e não consigo fazer isso funcionar.

Aqui está um MWE onde o índice e as páginas espelhadas estão corretas, MAS não quero que a página com a "Parte 1" ou a página em branco oposta seja impressa:

\documentclass[twoside,chapterprefix,headings=big]{scrbook}

\usepackage{blindtext}
\usepackage{mwe}


\makeatletter
\newcommand{\mychapter}[1]{%
  \begingroup
  \let\@makechapterhead\@gobble
  \chapter{#1}
  \endgroup
}
\makeatother

\begin{document}
\tableofcontents

\KOMAoptions{headings=openleft}
\part{It begins}
%beautiful artwork goes... around here somewhere?
\includegraphics[width=\textwidth]{example-image-golden}

\KOMAoptions{headings=openright}
\mychapter{a chapter}
 \begin{figure}[t!]
\centering
%beautiful chapter head artwork goes here
\includegraphics[width=\textwidth]{example-image-a}
\end{figure}
\blindtext

\mychapter{another chapter}
 \begin{figure}[t!]
\centering
%beautiful chapter head artwork goes here
\includegraphics[width=\textwidth]{example-image-b}
\end{figure}
\blindtext

\KOMAoptions{headings=openleft}
\part{The middle bit}
%beautiful artwork goes... around here somewhere?
\includegraphics[width=\textwidth]{example-image-golden}

\KOMAoptions{headings=openright}
\mychapter{yet another chapter}
\includegraphics[width=\textwidth]{example-image-c}

\blindtext
\end{document}

(Estamos fingindo que a imagem "dourada" é a arte de página inteira a ser usada no lugar da saída LaTeX da "Parte N: Título".)

Quero a página com "Parte N: Título" e a página em branco oposta suprimida (não impressa). O documento deve ir direto do índice para uma página dupla com a arte da peça à esquerda e o capítulo começando à direita.

Criar um \newcommand análogo a \mychapter não parece fazer nada, nem mesmo colocar algo interessante no log:

\makeatletter
\newcommand{\mypart}[1]{%
  \begingroup
  \let\@makeparthead\@gobble
  \part{#1}
  \endgroup
}
\makeatother

Tentando fingir uma parteomitindoo \part{It Begins}comando e, em vez disso, dopar o ToC com

\addcontentsline{toc}{part}{Part \thepart: It Begins}

resulta no título da parte aparecendo no índiceabaixocapítulo 1, e sem número de peça, além disso, não vejo como incrementar \thepart para que as partes subsequentes sejam numeradas corretamente. Tentar incrementá-lo manualmente \stepcounter{\thepart}gera um erro.

Se o guia Koma em inglês cobre isso, sinceramente perdi.

Obrigado a todos!

Responder1

Não tenho certeza se entendi exatamente o que você quer. Mas em vez de mexer nos detalhes internos da classe, sugiro definir um comando que faça exatamente o que você deseja e nada mais. AFAIK você quer:

  • iniciar uma nova página ímpar (para capítulos) ou uma nova página par (para partes)
  • pisar no contador
  • opcional, adicione uma entrada no sumário e uma marca para cabeçalhos de página
  • imprimir uma imagem

Estou usando um argumento opcional para a entrada do TOC e a marca. E também estou definindo uma variante em estrela sem aumentar o número e sem entrada no TOC e marca semelhante a \part*e \chapter*. Estou usando o argumento obrigatório para o arquivo de imagem:

\documentclass[chapterprefix,headings=big]{scrbook}

\usepackage{blindtext}
\usepackage{mwe}

\makeatletter
\NewDocumentCommand\ArtPart{som}{%
  \cleardoubleevenpage
  \IfBooleanTF{#1}{% star version: no TOC entry or page header
  }{%
    \refstepcounter{part}%
    \IfValueTF{#2}{% optional argument: Use for TOC entry and page header
      \addparttocentry{\thepart.}{#2}%
      \partmark{#2}%
    }{}%
  }%
  \noindent\includegraphics[width=\textwidth]{#3}%
  \par\nobreak
  \@afterindentfalse% don't indent first paragraph after the heading
  \@afterheading% don't allow page break here etc.
}

\NewDocumentCommand\ArtChapter{som}{%
  \cleardoubleoddpage
  \IfBooleanTF{#1}{% star version: no TOC entry or page header
  }{%
    \refstepcounter{chapter}%
    \IfValueTF{#2}{% optional argument: Use for TOC entry and page header
      \addchaptertocentry{\thechapter}{#2}%
      \chaptermark{#2}%
    }{}%
  }%
  \noindent\includegraphics[width=\textwidth]{#3}%
  \par\nobreak
  \@afterindentfalse% don't indent first paragraph after the heading
  \@afterheading% don't allow page break here etc.
}
\makeatother

\begin{document}
\tableofcontents

\ArtPart[It begins]{example-image-golden}


\ArtChapter[a chapter]{example-image-a}
\blindtext

\ArtChapter[another chapter]{example-image-b}
\blindtext

\ArtPart[The middle bit]{example-image-golden}

\ArtChapter[yet another chapter]{example-image-c}

\blindtext
\end{document}

insira a descrição da imagem aqui

Observe também que \thepartnão é o contador, mas a saída do contador. O contador seria parte portanto para manipular o contador você tem que usar \stepcounter{part}, \refstepcounter{part}, \addtocounter{part}{…}, e \setcounter{part}{…}, mas não \stepcounter{\thepart}. Observe também que não existe um predefinido \@makepartheadno KOMA-Script.

Para mais informações sobre \NewDocumentCommandconsulte“LaTeX para autores – versão atual”. Para obter mais informações sobre os comandos KOMA-Script usados, consulte o manual KOMA-Script.

Se você realmente deseja usar \parte \chapterdeve redefinir IMHO \chapterlineswithprefixformate \partlineswithprefixformatem vez de comandos internos:

\documentclass[chapterprefix,headings=big]{scrbook}

\usepackage{blindtext}
\usepackage{mwe}

\newcommand\mypart[2]{%
  \begingroup
    \KOMAoption{open}{left}%
    \renewcommand*{\partlineswithprefixformat}[3]{%
      \includegraphics[width=\textwidth]{#2}% this is the second argument of
                                % \mypart not of \partlineswithprefixformat
    }%
    \renewcommand*{\partheademptypage}{}% don't add an empty page after \part
    \part[#1]{#2}%
  \endgroup  
}

\newcommand\mychapter[2]{%
  \KOMAoption{open}{right}%
  \DeclareCommandCopy\ChapterLinesWithPrefixFormat\chapterlineswithprefixformat
  \renewcommand*{\chapterlineswithprefixformat}[3]{%
    \includegraphics[width=\textwidth]{#2}% this is the second argument of
                         % \mychapter not of \chapterlineswithprefixformat
  }%
  \chapter[#1]{#2}%
  \DeclareCommandCopy\chapterlineswithprefixformat\ChapterLinesWithPrefixFormat
}

\begin{document}
\tableofcontents

\mypart{It begins}{example-image-golden}


\mychapter{a chapter}{example-image-a}
\blindtext

\mychapter{another chapter}{example-image-b}
\blindtext

\mypart{The middle bit}{example-image-golden}

\mychapter{yet another chapter}{example-image-c}

\blindtext
\end{document}

insira a descrição da imagem aqui

Com isso, você ainda pode usar \RedeclareSectionCommandpara, por exemplo, alterar a distância vertical antes e depois do título = antes e depois da imagem.

Como você pode ver, não precisei de nenhum comando interno para esta segunda sugestão, mas apenas comandos que estão documentados no manual KOMA-Script para serem usados ​​por usuários ou usuários avançados ou que estão documentados em“LaTeX para autores – versão atual”.

Nota: eu não usei \begingroup…\endgroupin \mychapter, porque isso também quebraria a possibilidade de adicionar um \labelafter \mychaptere também quebraria o afterindent=falserecurso de \RedeclareSectionCommand. Em vez disso, armazenei o significado de \chapterlineswithprefixformatantes \chaptere o restaurei depois \chapter.

Para a primeira sugestão eu só precisei \@afterindentfalsedo \@afterheadingkernel LaTeX. Estes são comandos usuais para autores de classes/pacotes, mas não comandos internos do KOMA-Script.

informação relacionada