目录 - 字体参数

目录 - 字体参数

我的章节标题的字体、字体大小和颜色与文档的其余部分不同。我的目录的目标是使用与文档其余部分相同的颜色(黑色)和字体类型(傅立叶)。任何帮助都将不胜感激!

\documentclass[12pt]{article}
\usepackage[american]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{adforn}
\usepackage{xcolor}
\usepackage{microtype}
\usepackage{fourier}
\usepackage{Chivo}
\usepackage{lipsum}
\definecolor{MSLightBlue}{rgb}{0.31,0.506,0.741}

\usepackage{titlesec}
\newcommand{\coolsec}[1] % custom section title
    {   
        \titleformat{\section}{\Large\flushright}{\textcolor{MSLightBlue}{\textsf{\thesection\enskip|}}}{1em}{}
        \section{\textcolor{MSLightBlue}{\textsf{#1}}}
    }

\usepackage{tocloft}
\renewcommand{\cfttoctitlefont}{\hfill\LARGE}
\renewcommand{\cftaftertoctitle}{\hspace*{\fill}}

\addto\captionsamerican{% Replace "american" with the language you use
    \renewcommand{\contentsname}
    {\adforn{61}\quad Contents\quad\adforn{33}}}

\usepackage{titletoc}
\titlecontents{section}[0mm]{\large}{}{}{\dotfill\makebox[1em][l]{\thecontentspage}}

\begin{document}
\tableofcontents
\coolsec{FIRST}
\lipsum[1]
\newpage
\coolsec{SECOND}
\lipsum[2]
\newpage
\coolsec{THIRD}
\lipsum[3]
\end{document}

答案1

对于目录的格式,您可以使用numberless键和explicit选项 from titlesec(请注意,所有未编号的部分 - 参考书目等都将采用类似的格式),并\titlecontents{\section}以一致的方式使用。不需要 tocloft,只需要titletoc

这会产生比您已有的代码更简单的代码:

\documentclass[12pt, american]{article}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{adforn}
\usepackage{Chivo}
\usepackage{fourier}
\usepackage{microtype}
\usepackage{xcolor}
\definecolor{MSLightBlue}{rgb}{0.31,0.506,0.741}
\usepackage{lipsum}

\usepackage[explicit]{titlesec}
        \titleformat{\section}{\filleft\Large\color{MSLightBlue}\sffamily}{\thesection\enskip|}{1em}{#1}
        \titleformat{name=\section, numberless}[block]{\LARGE\filcenter}{}{0em}{\adforn{61}\quad#1\quad\adforn{33}}
\usepackage{titletoc}
\titlecontents{section}[0mm]{\large}{}{}{\enskip\titlerule*[1pc]{.}\contentspage}

\begin{document}

\tableofcontents

\section{FIRST}
\lipsum[1]
\newpage
\section{SECOND}
\lipsum[2]
\newpage
\section{THIRD}
\lipsum[3]

\end{document} 

在此处输入图片描述

相关内容