scrlayer-scrpage

scrlayer-scrpage

有人知道我该如何让这个文档只在第一页有这个页眉,而其他页面没有吗?此外,插入的程序代码“Form1.cs”应该从第一页开始。 在此处输入图片描述 在此处输入图片描述

\input{configuration.tex}
\begin{document}
\thispagestyle
\newcommand{\obenzentral}{\large{Hausaufgabe}\\ 
\Large{Wirtschaftsinformatik}}
\newcommand{\rechts}{\textcolor{gray}{\small{Ardit Abrashi}}}

\subsection*{MwSt-Rechner}
\begin{center}
  \includegraphics{Unbenannt.png}
\end{center} 
\subsection*{Code des Programms}

\lstinputlisting[language=c]{Form1.cs}

\end{document}


Preamble:



\documentclass[%
 paper=a4,       
 fontsize=10pt,  
 ngerman         
 ]{scrartcl}


 \usepackage[final]{graphicx}         
 \usepackage{subcaption}
 \usepackage{babel}                    
 \usepackage[german=quotes]{csquotes}  
 \enquote{...}



 \usepackage{sourcecodepro}
 \usepackage[default]{sourcesanspro}
 \usepackage{nimbusmononarrow}

 \usepackage[babel=true,final,tracking=smallcaps]{microtype}
 \DisableLigatures{encoding = T1, family = tt* }   




 \usepackage[usenames,x11names,final]{xcolor}



 \usepackage{mathtools}            
 \usepackage{amssymb}              
 \usepackage[bigdelims]{newtxmath} 
 \allowdisplaybreaks                
 \usepackage{bm}                    
 \usepackage{wasysym}               
 \usepackage{bbm}              




 \usepackage{tikz}
 \usetikzlibrary{arrows,arrows.meta}   
 \usetikzlibrary{calc}                 
 \usetikzlibrary{positioning}
 \tikzset{>=Latex}                   




 \usepackage{scrlayer-scrpage}
 \usepackage[top=3cm, bottom=3cm, left=2.5cm, right=2cm]{geometry}

 \clearscrheadfoot 
 \setheadsepline{0.4pt}                        
 \setfootsepline{0.4pt}                            
 \setkomafont{pagehead}{\bfseries}                 
 \setkomafont{pagefoot}{\normalfont\footnotesize}  

 \rohead{\rechts}
 \cohead{\obenzentral}                         
 \raggedbottom                                  
 \usepackage{setspace}                          
 \onehalfspacing                                   
 \setlength{\parindent}{0pt}                      
 \setlength{\parskip}{0.5\baselineskip}            





 \usepackage[%
 hidelinks,
 pdfpagelabels,
 bookmarksopen=true,
 bookmarksnumbered=true,
 linkcolor=black,
 urlcolor=SkyBlue2,
 plainpages=false,
 pagebackref,
 citecolor=black,
 hypertexnames=true,
 pdfborderstyle={/S/U},
 linkbordercolor=SkyBlue2,
 colorlinks=false,
 backref=false]{hyperref}
 \hypersetup{final}



 \usepackage{multicol}
 \usepackage[shortlabels]{enumitem}
 \setlist{itemsep=0pt}
 \setlist[enumerate]{font=\sffamily\bfseries}
 \setlist[itemize]{label=$\triangleright$}
 \usepackage{tabularx}



 \usepackage{listingsutf8}
 \lstset{
 belowcaptionskip=1\baselineskip,
 breaklines=true,
 showstringspaces=false,
 basicstyle=\ttfamily,
 keywordstyle=\bfseries\color{green!40!black},
 commentstyle=\itshape\color{purple!40!black},
 stringstyle=\color{orange},
 numbers=left,
 numberstyle=\footnotesize\ttfamily\color{gray},
 inputencoding=utf8/latin1,
 tabsize=4,
 }



 \newcommand{\BB}{\mathbb{B}}
 \newcommand{\CC}{\mathbb{C}}
 \newcommand{\NN}{\mathbb{N}}
 \newcommand{\QQ}{\mathbb{Q}}
 \newcommand{\RR}{\mathbb{R}}
 \newcommand{\ZZ}{\mathbb{Z}}
 \newcommand{\oh}{\mathcal{O}}

 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\wt}[1]{\widetilde{#1}}
 \newcommand{\wh}[1]{\widehat{#1}}

 \DeclareMathOperator{\id}{id}                       
 \DeclareMathOperator{\pot}{\mathcal{P}}             


 \DeclarePairedDelimiter{\absolut}{\lvert}{\rvert}    
 \DeclarePairedDelimiter{\ceiling}{\lceil}{\rceil}    
 \DeclarePairedDelimiter{\Floor}{\lfloor}{\rfloor}   
 \DeclarePairedDelimiter{\Norm}{\lVert}{\rVert}       
 \DeclarePairedDelimiter{\sprod}{\langle}{\rangle}    
 \DeclarePairedDelimiter{\enbrace}{(}{)}              
 \DeclarePairedDelimiter{\benbrace}{\lbrack}{\rbrack} 
 \DeclarePairedDelimiter{\penbrace}{\{}{\}}           
 \newcommand{\Underbrace}[2]{{\underbrace{#1}_{#2}}} 


 \newcommand{\abs}[1]{\absolut*{#1}}
 \newcommand{\ceil}[1]{\ceiling*{#1}}
 \newcommand{\flo}[1]{\Floor*{#1}}
 \newcommand{\no}[1]{\Norm*{#1}}
 \newcommand{\sk}[1]{\sprod*{#1}}
 \newcommand{\enb}[1]{\enbrace*{#1}}
 \newcommand{\penb}[1]{\penbrace*{#1}}
 \newcommand{\benb}[1]{\benbrace*{#1}}
 \newcommand{\stack}[2]{\makebox[1cm][c]{$\stackrel{#1}{#2}$}}

答案1

下面我删除了所有不相关的内容。

您可以为第一页定义一个页面样式附加项并将其与 一起使用\thispagestyle。其余页面将使用默认页面样式。

\documentclass[%
 paper=a4,       
 fontsize=10pt,  
 ngerman         
 ]{scrartcl}

\usepackage[]{graphicx}
\usepackage{xcolor}

\usepackage{scrlayer-scrpage}

% not doing this will keep the page numbers etc. on the second page
%\clearscrheadfoot 
\setheadsepline{0.4pt}                        
\setfootsepline{0.4pt}                            
\setkomafont{pagehead}{\bfseries}                 
\setkomafont{pagefoot}{\normalfont\footnotesize}  

\newpairofpagestyles{firstpage}
  {%
    \rohead{{\large Hausaufgabe}\\{\Large Wirtschaftsinformatik}}%
    \cohead{\textcolor{gray}{{\small Ardit Abrashi}}}%
  }

% just for dummy content
\usepackage{duckuments}

\begin{document}
\thispagestyle{firstpage}

\subsection*{MwSt-Rechner}
\begin{center}
  \includegraphics{example-image-duck}
\end{center} 
\subsection*{Code des Programms}

\blindduck[all]
\blindduck[all]

\end{document}

在此处输入图片描述

在此处输入图片描述

答案2

您还可以scrheadings对第一页和plain所有其他页面使用页面样式。

\PassOptionsToPackage{head height=27pt}{typearea}% removes the warning regarding the head height

%--- your preamble without the unrelated stuff:
\documentclass[%
  %paper=a4,% default
  fontsize=10pt,
  parskip=half-,% do not change \parskip and \parindent manually!
  ngerman,
  ]{scrartcl}
\usepackage{babel}

\usepackage{graphicx}
\usepackage{xcolor}

\usepackage[
  manualmark,
  headsepline=0.4pt,% do not use outdated macro \setheadsepline
  footsepline,% do not use outdated macro \setheadsepline
  plainfootsepline
  ]{scrlayer-scrpage}% sets page style scrheadings automatically

\pagestyle{plain}% plain style for all pages except first page

\clearpairofpagestyles% replaces outdated \clearscrheadfoot
\cfoot*{\pagemark}% pagemark in the center of the footer

\newcommand*\obenzentral[1]{\chead{#1}}
\newcommand*\rechts[1]{\rohead{#1}}

\setkomafont{pagehead}{\bfseries}
\setkomafont{pagefoot}{\normalfont\footnotesize}
%---

\obenzentral{%
  {\large Hausaufgabe}\\ 
  {\Large Wirtschaftsinformatik}%
}
\rechts{\textcolor{gray}{\small Ardit Abrashi}}

\usepackage{blindtext}% only for dummy text

\begin{document}

\thispagestyle{scrheadings}% page style scrheadings on first page
\subsection*{MwSt-Rechner}
\begin{center}
  \includegraphics{example-image}
\end{center} 

\subsection*{Code des Programms}
\Blindtext
\end{document}

在此处输入图片描述

headsepline如果所有页面上都应该有,则添加plainheadseplinescrlayer-scrpage选项中。

补充说明:

不要使用\setheadsepline来切换头带。这是一个过时的scrpage2宏。请使用选项headsepline=0.4pt或简单选项,headsepline因为0.4pt这是默认宽度。

不要手动更改\parindent\parsep。您可以使用选项parskip=halfparskip=half-

相关内容