![Цветной заголовок раздела не работает с опцией [leftmargin] titlesec](https://rvso.com/image/390761/%D0%A6%D0%B2%D0%B5%D1%82%D0%BD%D0%BE%D0%B9%20%D0%B7%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D0%B2%D0%BE%D0%BA%20%D1%80%D0%B0%D0%B7%D0%B4%D0%B5%D0%BB%D0%B0%20%D0%BD%D0%B5%20%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%B0%D0%B5%D1%82%20%D1%81%20%D0%BE%D0%BF%D1%86%D0%B8%D0%B5%D0%B9%20%5Bleftmargin%5D%20titlesec.png)
Я хочу, чтобы заголовок раздела был цветным. Все в порядке, когда я использую \titleformat
из пакета, titlesec
чтобы задать его.
Но когда я добавляю аргумент option [leftmargin]
, текст заголовка не меняет цвет. Что-то не так с моим кодом?
МВЭ:
\documentclass{article}
\usepackage{titlesec,xcolor}
\begin{document}
\titleformat{\section}
{\normalfont\bfseries\color{blue}}
{\thesection.}
{1em}
{}
\section{my colored section}
\titleformat{\section}[leftmargin]% only the optional argument "leftmargin" added
{\normalfont\bfseries\color{blue}}
{\thesection.}
{1em}
{}
\section{The Color Unchanged}
\end{document}
решение1
Обходной путь: поместите команду цвета во 2-й и 4-й аргументы.
\documentclass{article}
\usepackage{,xcolor, titlesec}
\begin{document}
\titleformat{\section}
{\normalfont\bfseries\color{blue}}
{\thesection.}
{1em}
{}
\section{my colored section}
\titleformat{\section}[leftmargin]% only the optional argument "leftmargin" added
{\normalfont\bfseries}
{\color{blue}\thesection.}
{1em}
{\color{blue}}
\section{The Color Unchanged}
\end{document}