
He buscado y buscado aquí una posible respuesta, pero me estoy quedando corto. Incluso hice referencia a las instrucciones de titlesec .pdf y todavía no tengo ni idea. Tengo un problema con mi \chapter
cuerpo principal y digo que le falta un cero.
Chapter 1.
! Missing number, treated as zero.
<to be read again>
\relax
l.39 \chapter{Spanning Tree Protocol Concepts}
El error está en mi primer capítulo.
Estoy escribiendo mis notas y para cada capítulo quiero mostrar "capítulo 1" y luego "este es el título del capítulo". Las secciones no las quiero numeradas, por eso uso un archivo \section*
. ¿Alguna idea?
\documentclass{report}
\usepackage[letterpaper,margin=1in]{geometry}
%\usepackage{fancyhdr}
\usepackage{amsmath ,amsthm ,amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{lipsum}
\usepackage{tabto}
\usepackage{enumitem}
\usepackage{bookmark}
\usepackage{booktabs}
\usepackage{titlesec}
\usepackage{parskip}
%\usepackage{indentfirst} used to indent first paragraph
%%%CHAPTER FORMAT/SPACING
\titleformat{\chapter}[display] %cmd and shape
{\normalfont\LARGE\bfseries} %textformat \typeoffont\size\ifits bold?
{Chapter \thechapter}%Label
{1pt} %seperaton from num to title name
{} %before code (blank means default)
\titlespacing{\chapter}{}{}{4pt} %cmd left margin befoe titel and after title
%%%SECTION FROMAT/SPACING
\titleformat{\section}
{\normalfont\Large\bfseries}
{\thesection}{}{}
\titlespacing{\section}{}{5pt}{5pt}
\linespread{0.7}
\setlist{nosep}
\setlength{\intextsep}{1pt}
\setlength{\parskip}{0pt}
\begin{document}
%\maketitle{ICND2 Note}
\part{LAN Switching}
\chapter{Spanning Tree Protocol Concepts}
\section*{Spanning Tree Protocol IEEE 802.1}%\pdfbookmark{STP} {ch:1:sec:2}
-Prevents loops when redundant links are used\\
-STP main goals
\begin{enumerate}
\item All devices in a VLAN can send frames to all others
\item Frames do not loop around (short life)
\end{enumerate}
-Checks each interface before send and receiving to prevent loops \\
-Consist of 2 states \textbf{Forwarding} \& \textbf{Blocking}
\section*{The Need for Spanning Tree} %\\pdfbookmark{Need for STP}
/end{document}
Respuesta1
El comando \titlespacing
espera tres longitudes.
entonces deberían ser algo como
\titlespacing{\chapter}{0pt}{0pt}{4pt}
y
\titlespacing{\section}{0pt}{5pt}{5pt}
También tienes /end{document}
en lugar de\end{document}
No sé qué intentas lograr, pero este es tu MWE modificado:
\documentclass{report}
\usepackage[letterpaper,margin=1in]{geometry}
%\usepackage{fancyhdr}
\usepackage{amsmath ,amsthm ,amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{lipsum}
\usepackage{tabto}
\usepackage{enumitem}
\usepackage{bookmark}
\usepackage{booktabs}
\usepackage{titlesec}
\usepackage{parskip}
%\usepackage{indentfirst} used to indent first paragraph
%%%CHAPTER FORMAT/SPACING
\titleformat{\chapter}[display] %cmd and shape
{\normalfont\LARGE\bfseries} %textformat \typeoffont\size\ifits bold?
{Chapter \thechapter}%Label
{1pt} %seperaton from num to title name
{} %before code (blank means default)
\titlespacing{\chapter}{0pt}{0pt}{4pt} %cmd left margin befoe titel and after title
%%%SECTION FROMAT/SPACING
\titleformat{\section}
{\normalfont\Large\bfseries}
{\thesection}{1em}{}
\titlespacing{\section}{0pt}{5pt}{5pt}
\linespread{0.7}
\setlist{nosep}
\setlength{\intextsep}{1pt}
\setlength{\parskip}{0pt}
\begin{document}
%\maketitle{ICND2 Note}
\part{LAN Switching}
\chapter{Spanning Tree Protocol Concepts}
\section*{Spanning Tree Protocol IEEE 802.1}%\pdfbookmark{STP} {ch:1:sec:2}
-Prevents loops when redundant links are used\\
-STP main goals
\begin{enumerate}
\item All devices in a VLAN can send frames to all others
\item Frames do not loop around (short life)
\end{enumerate}
-Checks each interface before send and receiving to prevent loops \\
-Consist of 2 states \textbf{Forwarding} \& \textbf{Blocking}
\section*{The Need for Spanning Tree} %\\pdfbookmark{Need for STP}
\end{document}
Producción
Tenga en cuenta que también le falta una longitud en
\titleformat{\section}
{\normalfont\Large\bfseries}
{\thesection}{}{}
debería ser algo así como
\titleformat{\section}
{\normalfont\Large\bfseries}
{\thesection}{1em}{}
Simplemente no te diste cuenta porque en el MWE sólo tienes secciones sin numerar.
Respuesta2
Sugeriría una pequeña mejora: las líneas que comienzan con un guión tienen una estructura detallada, por lo que solía enumitem
formatear itemize
con endash
es. Faltaba una longitud como cuarto argumento de \titleformat{\section}{…}
:
\documentclass{report}
\usepackage[letterpaper,margin=1in]{geometry}
%\usepackage{fancyhdr}
\usepackage{amsmath ,amsthm ,amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{lipsum}
\usepackage{tabto}
\usepackage{enumitem}
\usepackage{bookmark}
\usepackage{booktabs}
\usepackage{titlesec}
\usepackage{parskip}
%\usepackage{indentfirst} used to indent first paragraph
\setlist[itemize, 1]{etiqueta = \textendash}
%%%CHAPTER FORMAT/SPACING
\titleformat{\chapter}[display] %cmd and shape
{\normalfont\LARGE\bfseries} %textformat \typeoffont\size\ifits bold?
{Chapter \thechapter}%Label
{1pt} %seperation from num to title name
{} %before code (blank means default)
\titlespacing{\chapter}{0pt}{0pt}{4pt} %cmd left margin befoe titel and after title
%%%SECTION FORMAT/SPACING
\titleformat{\section}
{\normalfont\Large\bfseries}
{\thesection}{0.5em}{}
\titlespacing{\section}{0pt}{5pt}{5pt}
\linespread{0.7}
\setlist{nosep}
\setlength{\intextsep}{1pt}
\setlength{\parskip}{0pt}
\begin{document}
%\maketitle{ICND2 Note}
\part{LAN Switching}
\chapter{Spanning Tree Protocol Concepts}
\section*{Spanning Tree Protocol IEEE 802.1}%\pdfbookmark{STP} {ch:1:sec:2}
\begin{itemize}[wide = 0pt]
\item Prevents loops when redundant links are used
\item STP main goals
\begin{enumerate}[wide = 1.9em, leftmargin=3.15em]
\item All devices in a VLAN can send frames to all others Text text text text text text text text text text text text text text text text text text text text text text
\item Frames do not loop around (short life)
\end{enumerate}
\item Checks each interface before send and receiving to prevent loops
\item Consist of 2 states \textbf{Forwarding} \& \textbf{Blocking}
\end{itemize}
\section*{The Need for Spanning Tree} %\\pdfbookmark{Need for STP}
\end{document}