\titlesec и chapter§ion отсутствует ошибка нуля

\titlesec и chapter§ion отсутствует ошибка нуля

Я искал и искал здесь возможный ответ, но мне не хватает. Я даже ссылался на инструкции titlesec .pdf и все еще без понятия. У меня проблема с моим \chapterв основном теле, говорят, что не хватает нуля.

Chapter 1.
! Missing number, treated as zero.
<to be read again> 
                   \relax 
l.39 \chapter{Spanning Tree Protocol Concepts}

Ошибка в первой главе.

Я печатаю свои заметки и для каждой главы хочу отобразить «глава 1», а затем «это название главы». Разделы я не хочу нумеровать, поэтому я использую \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


%%%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}

решение1

Команда \titlespacingожидает три длины.

так что они должны быть чем-то вроде

\titlespacing{\chapter}{0pt}{0pt}{4pt}

и

\titlespacing{\section}{0pt}{5pt}{5pt}

Также у вас есть /end{document}вместо\end{document}

Я не знаю, чего вы пытаетесь добиться, но вот ваш модифицированный MWE:

\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} 

Выход

введите описание изображения здесь

Обратите внимание, что вы также пропустили длину в

\titleformat{\section}
    {\normalfont\Large\bfseries}
    {\thesection}{}{}

Это должно быть что-то вроде

\titleformat{\section}
    {\normalfont\Large\bfseries}
    {\thesection}{1em}{}

Вы просто этого не заметили, потому что в MWE есть только ненумерованные разделы.

решение2

Я бы предложил небольшое улучшение: ваши строки, начинающиеся с дефиса, имеют структуру itemize, поэтому я использовал enumitemформатирование itemizeс помощью endashes. Длина отсутствовала как 4-й аргумент \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]{label = \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} 

введите описание изображения здесь

Связанный контент