關於 scrlayer-scrpage 的編譯錯誤

關於 scrlayer-scrpage 的編譯錯誤

我的一個問題的解決方案對於提供它的人來說效果很好,但在編譯過程中會導致錯誤“Missing \begin{document}.\ofoot*{\pagemark”。難道是我的安裝、軟體包、作業系統有問題嗎?對此線上乳膠編譯器同樣的錯誤阻止他產生輸出,所以我可能沒有問題,但程式碼需要更改嗎?

\documentclass[12pt,a4paper,listof=flat,oneside]{scrartcl}
\KOMAoptions{captions=tableheading}
\usepackage{nicefrac}
\usepackage{scrlayer-scrpage}
\ihead{\headmark}
\chead*{}
\ofoot*{\pagemark}
\cfoot*{}
\pagestyle{scrheadings}
\automark[section]{section}
\setkomafont{pagehead}{\normalfont}
\KOMAoptions{
    captions=tableheading,
    headsepline=true,
    markcase=upper}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{xfrac}
\usepackage{xspace}
\newcommand{\eg}{\mbox{e.\,g.}\xspace}
\newcommand{\Eg}{\mbox{E.\,g.}\xspace}
\usepackage[english]{babel} 
\usepackage[left=3.00cm, right=3.00cm, top=2.00cm, bottom=2.5cm, includeheadfoot]{geometry} 
\usepackage[onehalfspacing]{setspace} 
\usepackage{lmodern}
%\usepackage{helvet}
%\renewcommand{\familydefault}{\sfdefault} 
%\fontfamily{phv}\selectfont
\usepackage{color}
\usepackage[
  pdftoolbar = false,
  pdfmenubar = false, 
  pdftitle   = mwe,
  pdfauthor  = {author},
  colorlinks,
  allcolors =  {blue},
  bookmarks         = true,
  bookmarksopen     = true, 
  bookmarksnumbered = true
]{hyperref}
\usepackage{subcaption}

\begin{document} \thispagestyle{plain.scrheadings} \section{Chapter one} \label{sec:ChapterOne} This text shows the current options that I have used for the printed version of my document. What and why would you change something? \begin{itemize} \item Referencing in blue. \Eg: Chapter one on page \ref{sec:ChapterOne} \item In-text math mode I use tfrac or nicefrac like this $\tfrac{1}{2}$ or this $\nicefrac{1}{2}$ and dfrac in the stand-alone equations. Or is sfrac of the xfrac package the way to go? $\sfrac{1}{2}$. What is the difference? \item Different fonts for print-out and digital copy? \Eg helvet for pdf for no serifs? \end{itemize} \newpage Thats what the pagestyle I have choosed looks like, but there is a warning about fancyhdr, how to produce the same output with KOMA?

\begin{figure}[!htbp] \null\hfill \begin{minipage}[b]{0.4\linewidth} \centering \includegraphics[width=\textwidth]{example-image-a} \subcaption{Example A}\label{fig:a} \end{minipage} \hfill \begin{minipage}[b]{0.4\linewidth} \centering \includegraphics[width=\textwidth]{example-image-b} \subcaption{Example B}\label{fig:b} \end{minipage} \hfill\null \caption{Two figures with subcaption and minipage} \end{figure} \end{document}

答案1

提到的線上編譯器使用非常舊的 KOMA-Script 版本:

文檔類別:scrartcl 2013/12/19 v3.12 KOMA-Script文檔類別(文章)

目前版本為 3.22,3.23 版本將很快在 CTAN 上提供。等的加星號版本\ihead是在 3.14 版本中引入的。

如果無法更新,則使用:

\usepackage[automark,markcase=upper,headsepline]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead{\headmark}
\ofoot[\pagemark]{\pagemark}

完整的例子:

\documentclass{scrartcl}
\usepackage[automark,headsepline,markcase=upper]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead{\headmark}
\ofoot[\pagemark]{\pagemark}

\usepackage{blindtext}
\begin{document}
\thispagestyle{plain}
{\huge\KOMAScriptVersion\par}
\blinddocument
\end{document}

問題中提到的線上編譯器的輸出:

在此輸入影像描述

答案2

發布的程式碼給出

! Paragraph ended before \@fileswith@ptions was complete.

因為 hyperref 選項中有空行。

如果你刪除它

\usepackage[
  pdftoolbar = false,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<<<<<<<<<<,
  pdfmenubar = false, 
  pdftitle   = mwe,
  pdfauthor  = {author},
  colorlinks,
  allcolors =  {blue},
  bookmarks         = true,
  bookmarksopen     = true, 
  bookmarksnumbered = true
]{hyperref}

然後它給出了錯誤

! Undefined control sequence.
<argument> \undefinedpagestyle 

l.48 \thispagestyle{leer}

我無法猜測這是否是已定義的頁面樣式的拼字錯誤,或者是否缺少該頁面樣式的定義。但如果你刪除它,那麼:

%\thispagestyle{leer}

然後文檔運行沒有錯誤。

相關內容