我如何返回正常的 ToC 格式?

我如何返回正常的 ToC 格式?

titlesec我使用带有(和mdframed,但带有 时也会发生这种情况)的样式部分格式tcolorbox,它会改变目录的样式。
我该如何将其恢复为正常样式? (见下图和文件)

% Preview source code

%% LyX 2.3.0 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[a4paper,hebrew,american]{article}
\usepackage{fontspec}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\parindent}{0bp}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\AtBeginDocument{
\renewcommand\footnoterule{%
  \kern -3pt
  \hbox to \textwidth{\hfill\vrule height 0.4pt width .4\textwidth}
  \kern 2.6pt
}}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage[many]{tcolorbox}
\usepackage[framemethod=TikZ,framemethod=pstricks]{mdframed}
%\titleformat{\section}
%  {\normalfont\bfseries\itshape\fontsize{12.8}{14}\selectfont}
%  {}{0pt}
%  {\begin{tcolorbox}\thesection\hskip0.7em#1\end{tcolorbox}}[]


\mdfdefinestyle{mystyle}{backgroundcolor=gray!40,shadow=true,roundcorner=8pt}
\titleformat{\section}
  {\normalfont\bfseries\itshape\fontsize{12.8}{14}\selectfont}
  {}{0pt}
  {\begin{mdframed}[style=mystyle]\thesection\hskip0.7em#1\end{mdframed}}

\makeatother

\usepackage{polyglossia}
\setdefaultlanguage[variant=american]{english}
\setotherlanguage{hebrew}
\begin{document}

\section{Hello}

\section{abcd}

\tableofcontents{}


\end{document}

在此处输入图片描述

谢谢你!

答案1

使用numberless密钥:此代码仅删除mdframed

\titleformat{name=\section, numberless}%
{\normalfont\bfseries\itshape\fontsize{12.8}{14}\selectfont}{}{0pt}{#1}

但您也可以修改其他功能,还可以使用 修改未编号部分的间距\titlespacing{name=\section,numberless}{...}

对于完全正常的 toc 格式(即正常的部分格式),使用

\titleformat{name=\section, numberless}
{\normalfont\Large\bfseries}{}{0pt}{#1}

相关内容