Latex 在 \section 上抛出错误

Latex 在 \section 上抛出错误

当我尝试编译 tex 文件时,同一行会引发两个错误。

错误 1

! Missing number, treated as zero.
<to be read again>
}
l.188 \section{Introdução}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

错误 2

! Illegal unit of measure (pt inserted).
<to be read again>
}
l.188 \section{Introdução}
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.

这个精简版本的 .tex 文件中倒数第三行出现错误:

% KOMA-Script Presentation
\documentclass[
paper=128mm:96mm, % The same paper size as used in the beamer class
paper=landscape,
fontsize=11pt, % Font size
pagesize, % Write page size to dvi or pdf
%parskip=half-, % Paragraphs separated by half a line
]{scrartcl} % KOMA script (article)

\linespread{1} % Increase line spacing for readability


% Colors
\usepackage[table]{xcolor}   % Required for custom colors
% Define a few colors for making text stand out within the presentation
\definecolor{mygreen}{RGB}{44,85,17}
\definecolor{myblue}{RGB}{34,31,217}
\definecolor{mybrown}{RGB}{194,164,113}
\definecolor{myred}{RGB}{255,66,56}
% Use these colors within the presentation by enclosing text in the commands below
\newcommand*{\mygreen}[1]{\textcolor{mygreen}{#1}}
\newcommand*{\myblue}[1]{\textcolor{myblue}{#1}}
\newcommand*{\mybrown}[1]{\textcolor{mybrown}{#1}}
\newcommand*{\myred}[1]{\textcolor{myred}{#1}}

% Margins
\usepackage[ % Page margins settings
includeheadfoot,
top=-1mm,
bottom=1.5mm,
left=1mm,
right=3.5mm,
headsep=0mm,
footskip=8.5mm
]{geometry}

% Fonts
\usepackage[T1]{fontenc}     % For correct hyphenation and T1 encoding
\usepackage{lmodern} % Default font: latin modern font
%\usepackage{fourier} % Alternative font: utopia
%\usepackage{charter} % Alternative font: low-resolution roman font
\renewcommand{\familydefault}{\sfdefault} % Sans serif - this may need to be commented to see the alternative fonts

% Various required packages
\usepackage{amsthm} % Required for theorem environments
\usepackage{bm} % Required for bold math symbols (used in the footer of the slides)
\usepackage{graphicx} % Required for including images in figures
\usepackage{tikz} % Required for colored boxes
\usepackage{booktabs} % Required for horizontal rules in tables
\usepackage{multicol} % Required for creating multiple columns in slides
\usepackage{lastpage} % For printing the total number of pages at the bottom of each slide

\usepackage{microtype} % Better typography
\usepackage{tocstyle} % Required for customizing the table of contents

% Slide layout configuration
\usepackage{scrpage2} % Required for customization of the header and footer
\pagestyle{scrheadings} % Activates the pagestyle from scrpage2 for custom headers and footers
\clearscrheadfoot % Remove the default header and footer
\setkomafont{pageheadfoot}{\normalfont\color{black}\sffamily} % Font settings for the header and footer

% Sets vertical centering of slide contents with increased space between paragraphs/lists
\makeatletter
\renewcommand*{\@textbottom}{\vskip \z@ \@plus 1fil}
\newcommand*{\@texttop}{\vskip \z@ \@plus .5fil}
\addtolength{\parskip}{\z@\@plus .25fil}
\makeatother

% Remove page numbers and the dots leading to them from the outline slide
\makeatletter
\newtocstyle[noonewithdot]{nodotnopagenumber}{\settocfeature{pagenumberbox}{\@gobble}}
\makeatother
\usetocstyle{nodotnopagenumber}



\AtBeginDocument{\renewcaptionname{english}{\contentsname}{\Large Outline}} % Change the name of the table of contents

% Header configuration - if you don't want a header remove this block
\ihead{
\hspace{-2mm}
\begin{tikzpicture}[remember picture,overlay]
\node [xshift=\paperwidth/2,yshift=-\headheight+18] (mybar) at (current page.north west)[rectangle,fill,inner sep=0pt,minimum width=\paperwidth,minimum height=2\headheight,top color=myblue!64,bottom color=myblue]{}; % Colored bar
%\node[below of=mybar,yshift=3.3mm,rectangle,shade,inner sep=0pt,minimum width=128mm,minimum height =1.5mm,top color=black!50,bottom color=white]{}; % Shadow under the colored bar shadow
\end{tikzpicture}
%\color{white}\runninghead} % Header text defined by the \runninghead command below and colored white for contrast
\color{white}\currtitle}

% Footer configuration
%\setlength{\footheight}{7mm} % Height of the footer
\addtokomafont{pagefoot}{\tiny } % Small font size for the footnote

\ifoot{% Left side
\hspace{-2mm}
\begin{tikzpicture}[remember picture,overlay]
%\node [xshift=\paperwidth/2,yshift=\footheight] at (current page.south west)[rectangle,fill,inner sep=0pt,minimum width=\paperwidth,minimum height=3pt,top color=myblue,bottom color=myblue]{}; % Green bar
\end{tikzpicture}
\myauthor\ \raisebox{0.2mm}{$\bm{\vert}$}\ \myuni % Left side text
}

\ofoot[\pagemark/\pageref{LastPage}\hspace{-2mm}]{\pagemark/\pageref{LastPage}\hspace{-2mm}} % Right side

% Section spacing - deeper section titles are given less space due to lesser importance
\usepackage{titlesec} % Required for customizing section spacing
\titlespacing{\section}{0mm}{0mm}{0mm} % Lengths are: left, before, after
\titlespacing{\subsection}{0mm}{0mm}{-1mm} % Lengths are: left, before, after
\titlespacing{\subsubsection}{0mm}{0mm}{-2mm} % Lengths are: left, before, after
\setcounter{secnumdepth}{0} % How deep sections are numbered, set to no numbering by default - change to 1 for numbering sections, 2 for numbering sections and subsections, etc

% Theorem style
\newtheoremstyle{mythmstyle} % Defines a new theorem style used in this template
{0.5em} % Space above
{0.5em} % Space below
{} % Body font
{} % Indent amount
{\sffamily\bfseries} % Head font
{} % Punctuation after head
{\newline} % Space after head
{\thmname{#1}\ \thmnote{(#3)}} % Head spec

\theoremstyle{mythmstyle} % Change the default style of the theorem to the one defined above
\newtheorem{theorem}{Theorem}[section] % Label for theorems
\newtheorem{remark}[theorem]{Remark} % Label for remarks
\newtheorem{algorithm}[theorem]{Algorithm} % Label for algorithms
\makeatletter % Correct qed adjustment

% The code for the box which can be used to highlight an element of a slide (such as a theorem)
\newcommand*{\mybox}[2]{ % The box takes two arguments: width and content
\par\noindent
\begin{tikzpicture}[mynodestyle/.style={rectangle,draw=myblue,thick,inner sep=2mm,text justified,top color=white,bottom color=white,above}]\node[mynodestyle,at={(0.5*#1+2mm+0.4pt,0)}]{ % Box formatting
\begin{minipage}[t]{#1}
#2
\end{minipage}
};
\end{tikzpicture}
\par\vspace{-1.3em}}

%   PRESENTATION INFORMATION
\newcommand*{\mytitle}{Title}
\newcommand*{\runninghead}{Running fead...} % Running head displayed on almost all slides
\newcommand{\currtitle}{\ttl@savetitle}
\newcommand*{\myauthor}{Author(s)...} % Presenters name(s)
\newcommand*{\mydate}{Date...} % Presentation date
\newcommand*{\myuni}{University...} % University or department

%----------------------------------------------------------------------------------------

\usepackage[brazilian, english]{babel} % Document language - required for customizing section titles
\usepackage[para,online,flushleft]{threeparttable}
\usepackage{blindtext}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}


\begin{document}
%\selectlanguage{brazilian} 
%----------------------------------------------------------------------------------------
%   TITLE SLIDE
%----------------------------------------------------------------------------------------

% Title slide - you may have to tweak a few of the numbers if you wish to make changes to the layout
\thispagestyle{empty} % No slide header and footer
\begin{tikzpicture}[remember picture,overlay] % Background box
\node [xshift=\paperwidth/2,yshift=\paperheight/2] at (current page.south west)[rectangle,fill,inner sep=0pt,minimum width=\paperwidth,minimum height=\paperheight/2.1,top color=myblue,bottom color=myblue]{}; % Change the height of the box, its colors and position on the page here
\end{tikzpicture}
% Text within the box
\begin{flushright}
\vspace{1.6cm}
\color{white}\sffamily
{\bfseries\Large\mytitle\par} % Title
\vspace{0.5cm}
\normalsize
\myauthor\par % Author name
\mydate\par % Date
\myuni\par

\vfill
\end{flushright}

\clearpage
%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

%\small\tableofcontents % Change the font size and print the table of contents - it may be useful to shrink the font size further if the presentation is full of sections
% To exclude sections/subsections from the table of contents, put an asterisk after \(sub)section like so: \section*{Section Name}

\section{Introdução}    < = = = = T H R O W S    E R R O R S
Introduction...
\end{document}

这是之前代码的精简版本,重现了同样的错误(倒数第三行)

% KOMA-Script Presentation
\documentclass[
paper=128mm:96mm, % The same paper size as used in the beamer class
paper=landscape,
fontsize=11pt, % Font size
pagesize, % Write page size to dvi or pdf
%parskip=half-, % Paragraphs separated by half a line
]{scrartcl} % KOMA script (article)

% Colors
\usepackage[table]{xcolor}   % Required for custom colors
\definecolor{myblue}{RGB}{34,31,217} % Define a few colors for making text stand out within the presentation
\newcommand*{\myblue}[1]{\textcolor{myblue}{#1}} % Use these colors within the presentation by enclosing text in the commands below


% Various required packages
\usepackage{bm} % Required for bold math symbols (used in the footer of the slides)
\usepackage{tikz} % Required for colored boxes

\usepackage{lastpage} % For printing the total number of pages at the bottom of each slide

\usepackage{microtype} % Better typography
\usepackage{tocstyle} % Required for customizing the table of contents

% Slide layout configuration
\usepackage{scrpage2} % Required for customization of the header and footer
\pagestyle{scrheadings} % Activates the pagestyle from scrpage2 for custom headers and footers
\clearscrheadfoot % Remove the default header and footer
\setkomafont{pageheadfoot}{\normalfont\color{black}\sffamily} % Font settings for the header and footer

\AtBeginDocument{\renewcaptionname{english}{\contentsname}{\Large Outline}} % Change the name of the table of contents

\ofoot[\pagemark/\pageref{LastPage}\hspace{-2mm}]{\pagemark/\pageref{LastPage}\hspace{-2mm}} % Right side

% Section spacing - deeper section titles are given less space due to lesser importance
\usepackage{titlesec} % Required for customizing section spacing
\titlespacing{\section}{0mm}{0mm}{0mm} % Lengths are: left, before, after
\titlespacing{\subsection}{0mm}{0mm}{-1mm} % Lengths are: left, before, after
\titlespacing{\subsubsection}{0mm}{0mm}{-2mm} % Lengths are: left, before, after
\setcounter{secnumdepth}{0} % How deep sections are numbered, set to no numbering by default - change to 1 for numbering sections, 2 for numbering sections and subsections, etc

\usepackage[brazilian, english]{babel} % Document language - required for customizing section titles

\begin{document}
\section{Introdução}    %< = = = = T H R O W S    E R R O R S
Introduction...
\end{document}

答案1

抱歉,但您的 MWE 看起来像一个非常旧且过时的模板:

不要将包titlesec与 KOMA-Script 类一起使用。这种组合会导致问题中提到的错误。

该软件包scrpage2已过时,已从 KOMA-Script 版本 3.30 中删除。该软件包tocstyle将在 KOMA-Script 版本 3.31 中删除。

以下是根据您的 MWE 提出的建议,但没有软件包titlesecscrpage2(替换为scrlayer-scrpage)和tocstyle。此外,我还删除了一些虚假空格并更正了其他内容。

\documentclass[
paper=128mm:96mm, % The same paper size as used in the beamer class
paper=landscape,
%fontsize=11pt, % Font size
pagesize, % Write page size to dvi or pdf
%parskip=half-, % Paragraphs separated by half a line
%footheight=7mm, % % Height of the footer
]{scrartcl} % KOMA script (article)

%\linespread{1} % Increase line spacing for readability


% Colors
\usepackage[table]{xcolor}   % Required for custom colors
% Define a few colors for making text stand out within the presentation
\definecolor{mygreen}{RGB}{44,85,17}
\definecolor{myblue}{RGB}{34,31,217}
\definecolor{mybrown}{RGB}{194,164,113}
\definecolor{myred}{RGB}{255,66,56}
% Use these colors within the presentation by enclosing text in the commands below
\newcommand*{\mygreen}[1]{\textcolor{mygreen}{#1}}
\newcommand*{\myblue}[1]{\textcolor{myblue}{#1}}
\newcommand*{\mybrown}[1]{\textcolor{mybrown}{#1}}
\newcommand*{\myred}[1]{\textcolor{myred}{#1}}

% Margins
\usepackage[ % Page margins settings
  includeheadfoot,
  top=-1mm,
  bottom=1.5mm,
  left=1mm,
  right=3.5mm,
  headsep=0mm,
  footskip=8.5mm
]{geometry}

% Fonts
\usepackage[T1]{fontenc}     % For correct hyphenation and T1 encoding
\usepackage{lmodern} % Default font: latin modern font
%\usepackage{fourier} % Alternative font: utopia
%\usepackage{charter} % Alternative font: low-resolution roman font
\renewcommand{\familydefault}{\sfdefault} % Sans serif - this may need to be commented to see the alternative fonts

% Various required packages
\usepackage{amsthm} % Required for theorem environments
\usepackage{bm} % Required for bold math symbols (used in the footer of the slides)
\usepackage{tikz} % Required for colored boxes, loads graphicx and other packages
\usepackage{booktabs} % Required for horizontal rules in tables
\usepackage{multicol} % Required for creating multiple columns in slides
\usepackage{lastpage} % For printing the total number of pages at the bottom of each slide

\usepackage{microtype} % Better typography

% Slide layout configuration
\usepackage[automark]{scrlayer-scrpage} % Required for customization of the header and footer
\clearpairofpagestyles % Remove the default header and footer
\AddLayersAtBeginOfPageStyle{scrheadings}{headerbg,footerbg}% add background layers
\setkomafont{pageheadfoot}{\normalfont\sffamily} % Font settings for the header and footer
\setkomafont{pagehead}{\color{white}}
% Header configuration - if you don't want a header remove this block
\DeclareNewLayer[
  background,
  head,
  hoffset=0pt,
  width=\paperwidth,
  mode=picture,
  contents=\putLL{\myblue{\rule{\layerwidth}{\layerheight}}}
]{headerbg}

\ihead{\rightbotmark}

% Footer configuration
\KOMAoptions{footwidth=\textwidth+2mm:0pt}
\setkomafont{pagefoot}{\color{black}\tiny} % Small font size for the footnote
%\DeclareNewLayer[
  %background,
  %foot,
  %hoffset=0pt,
  %width=\paperwidth,
  %mode=picture,
  %contents=\putLL{\myblue{\rule{\layerwidth}{\layerheight}}}
%]{footerbg}
\ifoot{\myauthor\ \raisebox{0.2mm}{$\bm{\vert}$}\ \myuni} % Left side text
\ofoot*{\pagemark/\pageref{LastPage}} % Right side

% Sets vertical centering of slide contents with increased space between paragraphs/lists
\makeatletter
\renewcommand*{\@textbottom}{\vskip \z@ \@plus 1fil}
\newcommand*{\@texttop}{\vskip \z@ \@plus .5fil}
\setparsizes{1em}{\z@\@plus .25fil}{0pt plus 1fil}
\makeatother

% Remove page numbers and the dots leading to them from the outline slide
\DeclareTOCStyleEntries[linefill=\hfill,pagenumberbox=\gobble]{section}{section,subsection,subsubsection}
\newcommand*\gobble[1]{}
\AfterTOCHead{\small}

\renewcaptionname{english}{\contentsname}{Outline} % Change the name of the table of contents
% Section spacing - deeper section titles are given less space due to lesser importance
\RedeclareSectionCommands[beforeskip=0pt,afterskip=0pt,afterindent=true,runin=false]{section,subsection,subsubsection}
\RedeclareSectionCommand[afterskip=-1mm]{subsection}
\RedeclareSectionCommand[afterskip=-2mm]{subsubsection}
\setcounter{secnumdepth}{\partnumdepth} % How deep sections are numbered

% Theorem style
\newtheoremstyle{mythmstyle} % Defines a new theorem style used in this template
  {0.5em} % Space above
  {0.5em} % Space below
  {} % Body font
  {} % Indent amount
  {\sffamily\bfseries} % Head font
  {} % Punctuation after head
  {\newline} % Space after head
  {\thmname{#1}\ \thmnote{(#3)}} % Head spec

\theoremstyle{mythmstyle} % Change the default style of the theorem to the one defined above
\newtheorem{theorem}{Theorem}[section] % Label for theorems
\newtheorem{remark}[theorem]{Remark} % Label for remarks
\newtheorem{algorithm}[theorem]{Algorithm} % Label for algorithms


% The code for the box which can be used to highlight an element of a slide (such as a theorem)
\newcommand*{\mybox}[2]{% The box takes two arguments: width and content
  \par\noindent
  \begin{tikzpicture}[mynodestyle/.style={rectangle,draw=myblue,thick,inner sep=2mm,text justified,top color=white,bottom color=white,above}]
    \node[mynodestyle,at={(0.5*#1+2mm+0.4pt,0)}]{% Box formatting
      \begin{minipage}[t]{#1}
      #2
      \end{minipage}%
    };
  \end{tikzpicture}
\par\vspace{-1.3em}}

%   PRESENTATION INFORMATION
\newcommand*{\mytitle}{Title}
\newcommand*{\myauthor}{Author(s)...} % Presenters name(s)
\newcommand*{\mydate}{Date...} % Presentation date
\newcommand*{\myuni}{University...} % University or department

%----------------------------------------------------------------------------------------

\usepackage[brazilian, english]{babel} % Document language - required for customizing section titles
\usepackage[para,online,flushleft]{threeparttable}
\usepackage{blindtext}% only for dummy text
\usepackage{amsmath}
%\usepackage[utf8]{inputenc}% only needed with outdated TeX distributions


\begin{document}
%\selectlanguage{brazilian} 
%----------------------------------------------------------------------------------------
%   TITLE SLIDE
%----------------------------------------------------------------------------------------

% Title slide - you may have to tweak a few of the numbers if you wish to make changes to the layout
\thispagestyle{empty} % No slide header and footer
\begin{tikzpicture}[remember picture,overlay] % Background box
  \node [xshift=\paperwidth/2,yshift=\paperheight/2] at (current page.south west)
    [rectangle,fill,inner sep=0pt,minimum width=\paperwidth,minimum height=\paperheight/2.1,top color=myblue,bottom color=myblue]{}; % Change the height of the box, its colors and position on the page here
\end{tikzpicture}
% Text within the box
\begin{flushright}
  \vspace{1.6cm}
  \color{white}\sffamily
  {\bfseries\Large\mytitle\par}% Title
  \vspace{0.5cm}
  \normalsize
  \myauthor\par % Author name
  \mydate\par % Date
  \myuni\par
  \vfill
\end{flushright}

\clearpage
%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

%\tableofcontents

\section{Introdução}    < = = = = T H R O W S    E R R O R S
Introduction
\clearpage
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\end{document}

在此处输入图片描述

相关内容