我有以下序言,我希望文本中不显示子节。我只想显示“Blah Blah”,而不是第 1 章“Blah Blah”。使用此代码我做到了,但文本中仍然显示子节。例如 2.5“blah blah”。我如何才能删除 2.5 呢?
\documentclass[a4paper,12pt]{book}
\usepackage{titlesec}
\titleformat{\chapter}[display]{\normalfont\huge\bfseries}{}{20pt}{\Huge}
\let\cleardoublepage\clearpage
\usepackage[english,greek]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{blindtext}
\usepackage[pdftex]{graphicx}
\usepackage[skip=2pt, font=small, labelformat = empty]{caption}
\newcommand{\gr}{\selectlanguage{greek}}
\newcommand{\en}{\selectlanguage{english}}
\usepackage{wrapfig}
\usepackage[paperwidth=17cm, paperheight=24cm]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage{textcomp}
\useshorthands{;}
\defineshorthand{;}{?}
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[LE]{\nouppercase{\leftmark}}
\fancyhead[RO]{\nouppercase{\rightmark}}
\fancyfoot[LE,RO]{\thepage}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{ \markboth{#1}{} }
\renewcommand{\sectionmark}[1]{ \markright{#1}{} }
答案1
无需titlesec
为此使用。让所有部分单元不编号的最简单方法是设置secnumdepth
为-2
(或-1
如果部分应该编号则设置为):
\documentclass{book}
\setcounter{secnumdepth}{-2}
\begin{document}
\chapter{Test chapter}
\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}
\end{document}