\titlesec 및 Chapter§ion 누락 0 오류

\titlesec 및 Chapter§ion 누락 0 오류

가능한 답변을 여기에서 살펴보고 살펴봤지만 부족합니다. 나는 titlesec .pdf 지침을 참조했지만 여전히 단서가 없습니다. \chapter본체에 0이 누락되어 있다는 문제가 있습니다 .

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

작은 개선을 제안하고 싶습니다. 하이픈으로 시작하는 줄은 항목별 구조를 가지므로 es 로 enumitem형식을 지정 했습니다 . 다음의 네 번째 인수에서 길이가 누락되었습니다 .itemizeendash\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} 

여기에 이미지 설명을 입력하세요

관련 정보