![Farbiger Abschnittstitel schlägt mit der Option [leftmargin] von titlesec fehl](https://rvso.com/image/390761/Farbiger%20Abschnittstitel%20schl%C3%A4gt%20mit%20der%20Option%20%5Bleftmargin%5D%20von%20titlesec%20fehl.png)
Ich möchte, dass mein Abschnittstitel farbig ist. Es ist in Ordnung, wenn ich es \titleformat
aus dem Paket verwende titlesec
, um es festzulegen.
Aber wenn ich das Optionsargument hinzufüge [leftmargin]
, ändert sich die Farbe des Titeltextes nicht. Stimmt etwas mit meinem Code nicht?
MWE:
\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}
Antwort1
Eine Problemumgehung: Setzen Sie den Farbbefehl in das 2. und 4. Argument.
\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}