![El título de la sección coloreada falla con la opción [margen izquierdo] de titlesec](https://rvso.com/image/390761/El%20t%C3%ADtulo%20de%20la%20secci%C3%B3n%20coloreada%20falla%20con%20la%20opci%C3%B3n%20%5Bmargen%20izquierdo%5D%20de%20titlesec.png)
Quiero que el título de mi sección esté coloreado. Está bien cuando uso \titleformat
el paquete titlesec
para configurarlo.
Pero cuando agrego el argumento de opción [leftmargin]
, el texto del título no cambia de color. ¿Hay algún problema con mi código?
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}
Respuesta1
Una solución alternativa: coloque el comando de color en el segundo y cuarto argumento.
\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}