titlesec의 [leftmargin] 옵션을 사용하면 컬러 섹션 제목이 실패합니다.

titlesec의 [leftmargin] 옵션을 사용하면 컬러 섹션 제목이 실패합니다.

섹션 제목에 색상을 지정하고 싶습니다. \titleformat패키지로부터 titlesec설정해서 사용하면 괜찮습니다 .

하지만 옵션 인수를 추가하면 [leftmargin]제목 텍스트의 색상이 변경되지 않습니다. 내 코드에 문제가 있나요?

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}

여기에 이미지 설명을 입력하세요

답변1

해결 방법: 두 번째 및 네 번째 인수에 color 명령을 넣습니다.

\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} 

여기에 이미지 설명을 입력하세요

관련 정보