答案1
这是一个使用titlesec
包重新定义\section*
标题的解决方案。
\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{titlesec}
\titleformat{name=\section,numberless}{\normalfont\Large\bfseries}{}{0em}{\colorthree}
\newcommand\colorthree[1]{\colorthreeX#1}
\newcommand\colorthreeX[3]{{\color{ForestGreen}#1#2#3}}
\usepackage{blindtext}
\begin{document}
\section*{Education}
\blindtext
\section*{Experience}
\blindtext
\end{document}
如果你还想要一条水平线,定义\section*
为
\usepackage[explicit]{titlesec}
\titleformat{name=\section,numberless}{\normalfont\Large\bfseries}{}{0em}{\colorthree{#1} \hrulefill}
答案2
下列etoolbox
补丁更新\@sect
以着色前三个字母全部章节标题。空格会被占用,因此您必须使用~
:
\documentclass{article}
\usepackage{etoolbox,xcolor}
\newcommand{\seccolfmt}[3]{\textcolor{green!80!black}{#1#2#3}}
\makeatletter
\patchcmd{\@sect}% <cmd>
{#8}% <search>
{\seccolfmt #8}% <replace>
{}{}% <success><failure>
\makeatother
\setcounter{secnumdepth}{0}% Don't number \section, \subsection, ...
\begin{document}
\section{Education}
\subsection{Experience}
\section{A~section}
\end{document}