scrlayer-scrpage:scrreprt 中第一页的页眉和页脚,无标题页

scrlayer-scrpage:scrreprt 中第一页的页眉和页脚,无标题页

这是对这个问题。我想重新创建一个 Word 模板以便在 LaTeX 中使用。

由于对分段级别的要求,我需要从 切换scrartclscrreprt。我知道我可以使用 增加编号级别\setcounter{secnumdepth}{VALUE},并且我也知道模仿 的行为scrartcl通常scrreprt不是一个好主意。但是,我想尝试一下。

我的模板在整个文档中有一个固定的页眉和一个页脚,但只在第一页。如下所示scrartcl

在此处输入图片描述 在此处输入图片描述

当我移动到时,scrreprt我在 documentclass 选项中隐藏了 titlepage titlepage=false。此外,感谢此主题,我隐藏了每章前的分页符。但是,当我这样做时,第一页的页眉和页脚以及第二页的页眉都丢失了。在第 3 页上,页眉回到了它应该在的位置。

为了将页眉和页脚恢复到第一页,我想我必须以某种方式进行修改\titlepagestyle,并且我必须修改每个章节的第一页\chapterpagestyle。不幸的是,我只找到了

\renewcommand*\titlepagestyle{firstpage}
\renewcommand*\chapterpagestyle{normalpage}

firstpagenormalpage在我的序言中定义。这解决了每个章节第一页的问题,但不幸的是 的问题没有解决\titlepagestyle。标题页的页眉在那里,但页脚丢失了。更改第一页的样式\thispagestyle{firstpage}似乎没有效果。

我错过了什么?


平均能量损失

\documentclass[titlepage=false,listof=totoc,bibliography=totoc,parskip=half-,11pt]{scrreprt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preamble                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ---------------------------
% Packages
% ---------------------------

\usepackage{anyfontsize}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{etoolbox}
\usepackage{geometry}
\usepackage{tabularx}
\usepackage[autooneside]{scrlayer-scrpage}

% Page geometry
\geometry{
  left=25mm,
  right=20mm,
  top=25mm,
  bottom=12mm,
  includefoot=false,
  headsep = \dimexpr2\baselineskip\relax,
  footskip = \dimexpr1\baselineskip+1.5mm\relax,
}

% ---------------------------
% Template adjustments
% ---------------------------

% Title
\makeatletter
\def\@maketitle{%
  \newpage
  % Zweck
  \begingroup%
    \normalsize%
    \bfseries%
    Test
    \par
  \endgroup%
  % Abstand
  \vskip 2\baselineskip
  % Authors
  \begingroup%
    \normalsize%
    \bfseries%
    \begin{tabularx}{\linewidth}{@{}X}%
      \@author
    \end{tabularx}
    \par
  \endgroup%
  % Abstand
  \vskip 1\baselineskip
  % Title
  \begingroup%
    \normalsize
    \bfseries
    \@title%
    \par%
  \endgroup%
  % Abstand
  \vskip 1\baselineskip
  \rule{\textwidth}{0.4pt}%
  %\vskip 1.5em%
  \vskip 1\baselineskip
  % Beschreibung des Vorhabens
  \begingroup%
    \normalsize
    \bfseries
    Schalala
    \par%
  \endgroup%
  \vskip 2\baselineskip
}
\makeatother

% Font sizes
\setkomafont{chapter}{\normalsize\bfseries}
\setkomafont{section}{\normalsize\bfseries}
\setkomafont{subsection}{\normalsize\bfseries}
\setkomafont{subsubsection}{\normalsize\bfseries}
\setkomafont{paragraph}{\normalsize\bfseries}
\setkomafont{subparagraph}{\normalsize\bfseries}

% ---------------------------
% Header/Footer commands
% ---------------------------

% Clear old  headers/footers
\clearpairofpagestyles

% Fonts for headers/footers
\setkomafont{pageheadfoot}{\sffamily\footnotesize}
\setkomafont{pagehead}{\sffamily}
\setkomafont{pagination}{}

% Trennlinien fuer Kopf und Fuss
\KOMAoptions{
  headsepline = false,
  footsepline = false,
  plainfootsepline = false,
}

% Create new header for title page
\newpairofpagestyles{firstpage}{%
  \ihead{Inner head}
  \ohead{Outer head}
  \ifoot{%
    %\hspace{-1em}
    \raisebox{1cm}[0pt][0pt]{%
      \begin{tabular}[t]{@{}l}
      \textbf{An organization}\\
      With an address\\
      and communication channels
      \end{tabular}
    }
  }
  \cfoot{%
    \raisebox{1cm}[0pt][0pt]{%
      Footer on 1\textsuperscript{st} page only
    }
  }
  \ofoot{%
    \raisebox{0.25cm}[0pt][0pt]{%
      {\fontsize{37}{44}\selectfont XYZ}
      %\normalsize
    }
  }
}
% Page Layout for normal pages
\newpairofpagestyles{normalpage}{%
  \ihead{Inner head}
  \ohead{Outer head}
  \ifoot{}
  \ofoot{}
}

\renewcommand*\titlepagestyle{firstpage}
\renewcommand*\chapterpagestyle{normalpage}

% Abstaende
\RedeclareSectionCommand[
  beforeskip=1\baselineskip,
  afterskip=1\baselineskip
]{chapter}

\RedeclareSectionCommand[
  beforeskip=1\baselineskip,
  afterskip=1\baselineskip
]{section}

\RedeclareSectionCommand[
  beforeskip=1\baselineskip,
  afterskip=1\baselineskip
]{subsection}

\RedeclareSectionCommand[
  beforeskip=1\baselineskip,
  afterskip=1\baselineskip
]{subsubsection}

\RedeclareSectionCommand[
  beforeskip=1\baselineskip,
  afterskip=1\baselineskip
]{paragraph}

\RedeclareSectionCommand[
  beforeskip=1\baselineskip,
  afterskip=1\baselineskip
]{subparagraph}

% 
\setlength{\parskip}{0cm}

% No chapter page break: https://tex.stackexchange.com/a/24067/44634
% for report:
%\makeatletter
%\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
%\makeatother
% for scrreprt:
\makeatletter
\patchcmd{\scr@startchapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title and author                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\title{Title}
\author{Author}
\date{\today}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Stuff at begin of document       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\AtBeginDocument{
  \maketitle
  \enlargethispage{-1cm}
  \thispagestyle{firstpage}
  \pagestyle{normalpage}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\chapter{First chapter}

\section{Section 1}

\Blindtext[2]

\section{Section 2}

\Blindtext[6]

\chapter{Second chapter}

\Blindtext[9]

\end{document}

答案1

不要修补内部 KOMA-Script 命令。如果您的章节应该像节一样运行,请使用以下代码重新声明章节级别

\RedeclareSectionCommand[
  style=section,
  indent=0pt
]{chapter}

在此处输入图片描述

代码:

\documentclass[titlepage=false,listof=totoc,bibliography=totoc,parskip=half-,11pt]{scrreprt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preamble                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---------------------------
% Packages
% ---------------------------
\usepackage{anyfontsize}
\usepackage[english]{babel}
\usepackage{blindtext}
%\usepackage{etoolbox}
\usepackage{geometry}
\usepackage{tabularx}
\usepackage[autooneside]{scrlayer-scrpage}% autooneside is default

% Page geometry
\geometry{
  left=25mm,
  right=20mm,
  top=25mm,
  bottom=12mm,
  includefoot=false,
  headsep = \dimexpr2\baselineskip\relax,
  footskip = \dimexpr1\baselineskip+1.5mm\relax,
}
% ---------------------------
% Template adjustments
% ---------------------------
% Title
\makeatletter
\def\@maketitle{%
  \newpage
  % Zweck
  \begingroup%
    \normalsize%
    \bfseries%
    Test
    \par
  \endgroup%
  % Abstand
  \vskip 2\baselineskip
  % Authors
  \begingroup%
    \normalsize%
    \bfseries%
    \begin{tabularx}{\linewidth}{@{}X}%
      \@author
    \end{tabularx}
    \par
  \endgroup%
  % Abstand
  \vskip 1\baselineskip
  % Title
  \begingroup%
    \normalsize
    \bfseries
    \@title%
    \par%
  \endgroup%
  % Abstand
  \vskip 1\baselineskip
  \rule{\textwidth}{0.4pt}%
  %\vskip 1.5em%
  \vskip 1\baselineskip
  % Beschreibung des Vorhabens
  \begingroup%
    \normalsize
    \bfseries
    Schalala
    \par%
  \endgroup%
  \vskip 2\baselineskip
}
\makeatother
% ---------------------------
% Header/Footer commands
% ---------------------------

% Clear old  headers/footers
\clearpairofpagestyles
% Fonts for headers/footers
\setkomafont{pageheadfoot}{\sffamily\footnotesize}
%\setkomafont{pagehead}{\sffamily}% not needed
%\setkomafont{pagination}{}% there is no \pagemark in your pagestyles??

% Trennlinien fuer Kopf und Fuss
%\KOMAoptions{
  %headsepline = false,% false is default
  %footsepline = false,% false is default
  %plainfootsepline = false,% false is default
%}

% Create new header for title page
\newpairofpagestyles{firstpage}{%
  \ihead{Inner head}
  \ohead{Outer head}
  \ifoot{%
    %\hspace{-1em}
    \raisebox{1cm}[0pt][0pt]{%
      \begin{tabular}[t]{@{}l}
      \textbf{An organization}\\
      With an address\\
      and communication channels
      \end{tabular}
    }
  }
  \cfoot{%
    \raisebox{1cm}[0pt][0pt]{%
      Footer on 1\textsuperscript{st} page only
    }
  }
  \ofoot{%
    \raisebox{0.25cm}[0pt][0pt]{%
      {\fontsize{37}{44}\selectfont XYZ}
      %\normalsize
    }
  }
}
% Page Layout for normal pages
\newpairofpagestyles{normalpage}{%
  \ihead{Inner head}
  \ohead{Outer head}
}

% \chapter should behave like a section
\RedeclareSectionCommand[
  style=section,
  indent=0pt
]{chapter}

% Abstaende
\RedeclareSectionCommands[
  beforeskip=1\baselineskip,
  afterskip=1\baselineskip,
  font=\normalsize
]{chapter,section,subsection,subsubsection,paragraph,subparagraph}

%\setlength{\parskip}{0cm}% <- remove this
\setlength{\parindent}{0pt}% instead option parskip=half- and \setlength{\parskip}{0cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title and author                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Title}
\author{Author}
\date{\today}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Stuff at begin of document       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AtBeginDocument{
  \maketitle
  \enlargethispage{-1cm}
  \thispagestyle{firstpage}
  \pagestyle{normalpage}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\chapter{First chapter}
\section{Section 1}
\Blindtext[2]
\section{Section 2}
\Blindtext[6]
\chapter{Second chapter}
\Blindtext[9]
\end{document}

补充说明:

如果所有部分级别都应使用相同的fontbeforeskipafterskip代码可以缩短:

\RedeclareSectionCommands[
  beforeskip=1\baselineskip,
  afterskip=1\baselineskip,
  font=\normalsize
]{chapter,section,subsection,subsubsection,paragraph,subparagraph}

选项autoonesideheadsepline=falsefootsepline=falseplainfootsepline=false为默认。

我不明白为什么你先设置 optionparskip=half-然后设置\setlength{\parskip}{0cm}。不要\parskip手动更改!在我看来,你既不想要 parskip 也不想要 parindent。然后你必须设置\parindent0pt。请注意,这样新段落的开头实际上并不可见。

normalstyle您可以使用默认样式,而不必定义新的页面样式scrheadings

相关内容