选项 firsthead 导致 scrlttr2 出现问题

选项 firsthead 导致 scrlttr2 出现问题

firsthead我在课堂上遇到了选项问题scrlttr2。请参阅附件代码。文档使用 进行编译,firsthead=off但当选项设置为 时firsthead=on,它会生成以下错误消息。

首页页首!缺失数字,视为零。

我不知道这是兼容性问题还是其他问题。我使用的许多 tex 文件都发生过这种情况。令人惊讶的是,同一个 tex 文件在我的工作笔记本电脑上编译得很好。

我的代码如下:

\documentclass[
pagenumber = off,       % Removes page numbers from page 2 onwards
parskip = half,         % Separates paragraphs with some whitespace, use parskip=full for more space or comment out to return to default
fromalign = right,      % Aligns the from address to the right
foldmarks=on,           % Prints small fold marks on the left of the page
addrfield=on,           % Set to false to hide the addressee section - you will then want to adjust the height of the body of the letter on the page by adding the following in this section: \makeatletter \@setplength{refvpos}{\useplength{toaddrvpos}} \makeatletter
fromphone = on,         % add phone
fromemail = on,         % add emaill
frommobilephone = on,   % add mobile phone
firstfoot = off,            % if first foot is on
firsthead = on
]{scrlttr2}

\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{url}
\usepackage{graphicx}
\usepackage{eurosym}
\usepackage[headheight=20pt, headsep=20pt]{geometry}
%\usepackage{showframe}
%\usepackage{datetime}
\usepackage{amsmath}
%\usepackage{gfsdidot}
%\usepackage{calligra}
\usepackage[hidelinks]{hyperref}
\usepackage{scrlayer-scrpage}
\usepackage{graphicx} % Um Grafiken (bspw. das Logo) einbinden zu können
\usepackage{blindtext}


\setlength{\parskip}{0.1\baselineskip}

\renewcommand*{\raggedsignature}{\raggedright} % Stop the signature from indenting

\LoadLetterOption{DIN} % Einstellungen für DIN 676 laden
\renewcommand*{\raggedsignature}{\raggedright}


\setkomavar{fromname}{Ct. Jack Sparrow}
\setkomavar{fromaddress}{Musterstr. 15, 05050 Musterstadt}
\setkomavar{frommobilephone}{+49 152 00000000}
\setkomavar{fromemail}{[email protected]}
\setlength{\parindent}{0pt}

\newcommand{\logo}[1]{\renewcommand{\logo}{#1}}

\newcommand{\Who}[1]{\renewcommand{\Who}{#1}}
\newcommand{\Title}[1]{\renewcommand{\Title}{#1}}

\Who{\huge Ct. Jack Sparrow \par} % Your name

\Title{Artist for Music and Dance} % Your title, leave blank for no title

\renewcaptionname{ngerman}{\customername}{Steuernummer}
\renewcaptionname{ngerman}{\invoicename}{Rechnungsnummer}


\setkomavar{customer}{222/333/00000}         % Steuernummer
\setkomavar{invoice}{2017-12-E001}          % Rechnungsnummer
\setkomavar{date}{\today}       % Datum         
\KOMAoptions{fromphone=on,fromfax=off}  
\setkomavar{subject}{Rechnung über erbrachte Leistungen}

\begin{document}    
    \begin{letter}{Receiver\\
                   His address\\
                   Pin, City}

        \opening{Sehr geehrte Damen und Herren,}

        \blindtext[2]

        \closing{Best Regards,}
    \end{letter}
\end{document}

答案1

将该行移至\usepackage[hidelinks]{hyperref}最后调用的包后,更改后的代码可以无错误地进行编译。请参阅以下 MWE 中包的更改顺序。

\documentclass[%
  pagenumber = off,       % Removes page numbers from page 2 onwards
  parskip = half,         % Separates paragraphs with some whitespace, use parskip=full for more space or comment out to return to default
  fromalign = right,      % Aligns the from address to the right
  foldmarks=on,           % Prints small fold marks on the left of the page
  addrfield=on,           % Set to false to hide the addressee section - you will then want to adjust the height of the body of the letter on the page by adding the following in this section: \makeatletter \@setplength{refvpos}{\useplength{toaddrvpos}} \makeatletter
  fromphone = on,         % add phone
  fromemail = on,         % add emaill
  frommobilephone = on,   % add mobile phone
  firstfoot = off,            % if first foot is on
  firsthead = on
]{scrlttr2}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{lmodern}

\usepackage{url}
\usepackage{graphicx} % Um Grafiken (bspw. das Logo) einbinden zu können
\usepackage{eurosym}
\usepackage[headheight=20pt, headsep=20pt]{geometry}
%\usepackage{showframe}
%\usepackage{datetime}
\usepackage{amsmath}
%\usepackage{gfsdidot}
%\usepackage{calligra}

\usepackage{scrlayer-scrpage}

\usepackage{blindtext}
\usepackage[hidelinks]{hyperref} % <====================================


\setlength{\parskip}{0.1\baselineskip}

\renewcommand*{\raggedsignature}{\raggedright} % Stop the signature from indenting

\LoadLetterOption{DIN} % Einstellungen für DIN 676 laden
\renewcommand*{\raggedsignature}{\raggedright}


\setkomavar{fromname}{Ct. Jack Sparrow}
\setkomavar{fromaddress}{Musterstr. 15, 05050 Musterstadt}
\setkomavar{frommobilephone}{+49 152 00000000}
\setkomavar{fromemail}{[email protected]}
\setlength{\parindent}{0pt}

\newcommand{\logo}[1]{\renewcommand{\logo}{#1}}

\newcommand{\Who}[1]{\renewcommand{\Who}{#1}}
\newcommand{\Title}[1]{\renewcommand{\Title}{#1}}

\Who{\huge Ct. Jack Sparrow \par} % Your name

\Title{Artist for Music and Dance} % Your title, leave blank for no title

\renewcaptionname{ngerman}{\customername}{Steuernummer}
\renewcaptionname{ngerman}{\invoicename}{Rechnungsnummer}


\setkomavar{customer}{222/333/00000}         % Steuernummer
\setkomavar{invoice}{2017-12-E001}          % Rechnungsnummer
\setkomavar{date}{\today}       % Datum         
\KOMAoptions{fromphone=on,fromfax=off}  
\setkomavar{subject}{Rechnung über erbrachte Leistungen}

\begin{document}    
    \begin{letter}{Receiver\\
                   His address\\
                   Pin, City}

        \opening{Sehr geehrte Damen und Herren,}

        \blindtext[2]

        \closing{Best Regards,}
    \end{letter}
\end{document}

它给出以下结果,没有任何错误消息:

生成第一页

相关内容