如何使用 KOMA-Script 为每个页面设置相同的模板

如何使用 KOMA-Script 为每个页面设置相同的模板

提前感谢您的帮助!

我想以这种方式设置 a5 文档 -每一页除了页码发生变化外,其他都类似。我只想像往常一样在页面中间添加注释。

我一直在尝试,但我通常使用考试课和 a4 页,所以我很困惑。

    \documentclass[a5paper,pagesize,11pt,bibtotoc,pointlessnumbers,
normalheadings,DIV=9,twoside=false]{scrbook}

% twoside, openright
\KOMAoptions{DIV=last}

\usepackage{trajan}

\linespread{1.05} 


\begin{document}

notes here

\end{document}

在此处输入图片描述

答案1

KOMA-Script 提供了包scrlayerscrlayer-scrpage来更改页眉和页脚。有几种可能的方法可以获得您想要的结果。在我看来,一个简单的例子是使用\ihead或定义整个页眉(包括双分隔线\ihead*)(有关区别,请参阅 KOMA-Script 手册):

\ihead*{\includegraphics[height=5.5\baselineskip,width=7em]{example-image}
  \parbox[b][5.5\baselineskip]{\dimeval{\linewidth-8em}}{\raggedright
    Topic x: xxx x xxxxxx xx\\
    xxxxxxxx xxx xxxxxxxx\\
    xxxxxx xxxx x xx xxxxxxxx xxxxxx xxxxxxx xxx\\
    01.10 xxxx 1/2\\
    \null
  }\\[-1ex]
  \makebox[0pt][l]{\rule[2pt]{\linewidth}{1pt}}%
  \rule{\linewidth}{1pt}
}

因为这个头部比通常的头部高很多,所以我们还需要增加头部高度。不增加头部高度的警告信息提供了有关所需高度的更多信息。

如果您想要(自动)运行标题(类似于页面样式headings),则需要\headmark在该标题定义中的某处使用。有关更多信息,请参阅 KOMA-Script 手册。

对于页脚,我们可以使用类似的解决方案。但由于页码应放在页脚中间较低的位置,我建议使用\ifoot*\cfoot*

\ifoot*{%
  \makebox[0pt][l]{\rule[2pt]{\linewidth}{1pt}}%
  \rule{\linewidth}{1pt}\\
  @copyright stuff hre\dots
}
\cfoot*{%
  \raisebox{-5\baselineskip}[0pt][0pt]{\pagemark}
}

由于高度原因,将再次出现警告信息。

关于页眉和页脚所需额外高度的完整示例可能是:

\documentclass[
  a5paper,
  % pagesize,11pt,% both are default and therefore not needed
  bibliography=totoc,% bibtotoc is deprecated and therefore replaced according
                     % to the warning message
  numbers=noenddot,% pointlessnumbers is deprecated and therefore replaced
                   % according to the warning message
  headings=normal,% normalheadings is deprecated and therefore replaced
                  % according to the warning message
  DIV=9,twoside=false,
  headinclude,
  headheight=87pt,% see the KOMA-Script manual and the warning message without
                  % this line
  footheight=24pt,% see the KOMA-Script manual and the warning message without
                  % this line
]{scrbook}

\KOMAoptions{DIV=last}

\usepackage{trajan}

\linespread{1.05}

\KOMAoptions{DIV=last}% moved according to the KOMA-Script manual, because it
                      % makes no sense before changing font an linespread.

\usepackage{graphicx}
\usepackage{blindtext}

\usepackage[manualmark]{scrlayer-scrpage}% or maybe automark, this
                                % is not clear due to missing information in
                                % the question.
\clearpairofpagestyles
\setkomafont{pageheadfoot}{\footnotesize}
\ihead*{\includegraphics[height=5.5\baselineskip,width=7em]{example-image}
  \parbox[b][5.5\baselineskip]{\dimeval{\linewidth-8em}}{\raggedright
    Topic x: xxx x xxxxxx xx\\
    xxxxxxxx xxx xxxxxxxx\\
    xxxxxx xxxx x xx xxxxxxxx xxxxxx xxxxxxx xxx\\
    01.10 xxxx 1/2\\
    \null
  }\\[-1ex]
  \makebox[0pt][l]{\rule[2pt]{\linewidth}{1pt}}%
  \rule{\linewidth}{1pt}
}
\ifoot*{%
  \makebox[0pt][l]{\rule[2pt]{\linewidth}{1pt}}%
  \rule{\linewidth}{1pt}\\
  @copyright stuff hre\dots
}
\cfoot*{%
  \raisebox{-5\baselineskip}[0pt][0pt]{\pagemark}
}
\renewcommand{\familydefault}{trjn}% If you want to the font as document default.

\begin{document}

\blindtext

\end{document}

在此处输入图片描述

如果您想要其他边距或页眉和文本区域之间的更小距离,请参阅包geometry

另一个建议是使用选项绘制一条分隔线headseplinefootsepline并使用两个新层添加第二条分隔线。此外,除了使用\raisebox降低页码之外,还可以向页面样式添加一个层:

\documentclass[
  a5paper,
  % pagesize,11pt,% both are default and therefore not needed
  bibliography=totoc,% bibtotoc is deprecated and therefore replaced according
                     % to the warning message
  numbers=noenddot,% pointlessnumbers is deprecated and therefore replaced
                   % according to the warning message
  headings=normal,% normalheadings is deprecated and therefore replaced
                  % according to the warning message
  DIV=9,twoside=false,
  headsepline,footsepline,footinclude=false,% see the KOMA-Script manual
%  headheight=87pt,% not used, to not lower the header, but this results in a warning
%  footheight=24pt,% no longer needed, because the lines are not part of the footer
]{scrbook}

\KOMAoptions{DIV=last}

\usepackage{trajan}

\linespread{1.05}

\KOMAoptions{DIV=last}% moved according to the KOMA-Script manual, because it
                      % makes no sense before changing font an linespread.

\usepackage{graphicx}
\usepackage{blindtext}

\usepackage[%
  autoenlargeheadfoot=false,% only warn but don't change height reserved for header or footer  
  manualmark,% or maybe automark, this is not clear due to missing information
             % in the question.
  plainheadsepline,plainfootsepline,% See the KOMA-Script manual for more information
  ]{scrlayer-scrpage}
\clearpairofpagestyles
\setkomafont{pageheadfoot}{\footnotesize}
\ihead*{\includegraphics[height=5.5\baselineskip,width=7em]{example-image}
  \parbox[b][5.5\baselineskip]{\dimeval{\linewidth-8em}}{\raggedright
    Topic x: xxx x xxxxxx xx\\
    xxxxxxxx xxx xxxxxxxx\\
    xxxxxx xxxx x xx xxxxxxxx xxxxxx xxxxxxx xxx\\
    01.10 xxxx 1/2\\
    \null
  }\\[-1ex]
}
\ifoot*{%
  @copyright stuff hre\dots
}

% Defining new layers for the second separation line.
% We simply clone the existing lines and raise or lower them:
\DeclareLayer[clone=scrheadings.head.below.line,addvoffset=-2pt]{scrheadings.head.below.line2}
\DeclareLayer[clone=scrheadings.foot.above.line,addvoffset=2pt]{scrheadings.foot.above.line2}
\DeclareLayer[clone=plain.scrheadings.head.below.line,addvoffset=-2pt]{plain.scrheadings.head.below.line2}
\DeclareLayer[clone=plain.scrheadings.foot.above.line,addvoffset=2pt]{plain.scrheadings.foot.above.line2}

% Define a new layer for the page number:
\DeclareLayer[foreground,foot,addvoffset=2cm,contents={\centering \pagemark\par}]{pagenumber}

% Add the new layers to the existing page styles:
\AddLayersToPageStyle{scrheadings}{scrheadings.head.below.line2,scrheadings.foot.above.line2,pagenumber}
\AddLayersToPageStyle{plain.scrheadings}{plain.scrheadings.head.below.line2,plain.scrheadings.foot.above.line2,pagenumber}

\renewcommand{\familydefault}{trjn}% If you want to the font as document default.

\begin{document}

\blindtext

\end{document}

在此处输入图片描述

甚至页眉中的图像和文本也可以使用单独的图层放置。有关定义新图层并将其添加到现有页面样式或定义新页面样式的更多信息,请参阅 KOMA-Script 手册。

相关内容