
答えがないか何度も探しましたが、見つかりません。titlesec .pdf の指示も参照しましたが、まだわかりません。\chapter
本体にゼロが 1 つ欠けているという問題があります。
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
3 つの長さが必要です。
つまり、次のような感じになるはずです
\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 構造になっているので、 esでenumitem
フォーマットしていました。4 番目の引数として長さがありませんでした。itemize
endash
\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}