![titlesec의 [leftmargin] 옵션을 사용하면 컬러 섹션 제목이 실패합니다.](https://rvso.com/image/390761/titlesec%EC%9D%98%20%5Bleftmargin%5D%20%EC%98%B5%EC%85%98%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%98%EB%A9%B4%20%EC%BB%AC%EB%9F%AC%20%EC%84%B9%EC%85%98%20%EC%A0%9C%EB%AA%A9%EC%9D%B4%20%EC%8B%A4%ED%8C%A8%ED%95%A9%EB%8B%88%EB%8B%A4..png)
섹션 제목에 색상을 지정하고 싶습니다. \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}