我必須使用這個包\usepackage{titlesec}
。
我對章節沒有任何問題。但是,當使用 時\subsection{..}
,枚舉消失。
問題:我的問題是我想要編號的小節,但 TexStudio 在我的文件中顯示未編號的小節
問題:如何繼續進行分段枚舉?
按照 pdf 的程式碼和圖像進行操作。
\documentclass[a4paper,12pt,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[explicit,clearempty,nobottomtitles*]{titlesec} % pretty titles
%\usepackage{titlesec} % pretty titles
\usepackage{graphicx} % \resizebox
\usepackage{xcolor} % \color, \textcolor
\usepackage{colortbl} % \cellcolor
\providecommand\phantomsection{} % just in case we're not using hyperref
% chapter style
\definecolor{chapcolor}{rgb}{0.33,0.73,0}
\newlength\Chapmargin \Chapmargin=10pt % extra margin at left of chapter title
\newlength\Chaplineext \Chaplineext=1.5in % extension of "hanging" bottom line
% section style
\newsavebox\Secbox % used to temporarily store the section label
\titleformat{\section}%
[hang]{}{}{0pt}%
{%
\sbox\Secbox{% temporarily save section label in order to measure it later
%~ \color{white}\bfseries\rmfamily\LARGE\textsuperscript\S\,\thesection% section number, in white over color, bold, roman, LARGE
\color{white}\bfseries\rmfamily\LARGE\thesection% section number, in white over color, bold, roman, LARGE
}%
\def\arraystretch{2}% better vertical margins (for this table only)
\arrayrulewidth=1pt% thicker lines (for this table only)
\begin{tabular}{cl@{}}% no margin at the end
\arrayrulecolor{chapcolor}% colored lines (for this table only)
\hline%
\hfill\cellcolor{chapcolor}\usebox\Secbox%
&%
\textcolor{chapcolor}{% needs to be outside of the parbox (and use \textcolor) or else it messes up line formatting
\parbox[t]{\dimexpr \textwidth-\wd\Secbox-3\tabcolsep\relax}{%
\raggedright% no stretching/hyphenation
\LARGE\rmfamily\bfseries\MakeUppercase{#1}% chapter title (roman, bold, uppercase)
}}%
\\%
\end{tabular}%
}
\begin{document}
\chapter{First Chapter}
\section{first Section}
\subsection{First Sub Section}
\subsubsection{First SubSub Section}
\subsection{Second Sub Section}
\end{document}
我得到什麼:
以及我想獲得什麼:
請注意,最後一個數字是透過刪除得到的\usepackage{titlesec}
答案1
感謝這些評論,很明顯我面臨著titlesec
.新版本解決了這個問題。欲了解更多信息,請參閱問題和答案這裡。
為了解決這個BUG:
下載正確的(沒有錯誤).sty
並替換舊的。
對於帶有 texlive 的 Ubuntu 18.04:
sudo wget http://mirrors.ctan.org/macros/latex/contrib/titlesec/titlesec.sty -O /usr/share/texlive/texmf-dist/tex/latex/titlesec/titlesec.sty
對於其他 Linux 發行版:
首先,運行locate /titlesec.sty
然後修改之前的程式碼。