titlesec
섹션 제목의 형식을 지정하기 위해 패키지를 사용하고 있습니다 . 프레임 모양의 배경색을 변경하고 싶습니다. 구체적으로 단색(프레임과 배경이 동일한 색상)의 파란색 프레임과 흰색 텍스트를 얻고 싶습니다.
\colorbox
형식으로 사용하는 순진한 접근 방식을 시도했지만 \titleformat
작동하지 않는 것 같습니다.
\documentclass{article}
\usepackage{xcolor}
\usepackage{titlesec}
\setcounter{secnumdepth}{0}
\newcommand{\mybox}[1]{
\colorbox{blue}{\textcolor{white}{#1}}
}
\titleformat{\section}
[frame]
{
\vspace{.8ex}%
\color{blue}\Large\normalfont\sffamily\mybox
}
{\thesection.}
{.5em}
{}
\begin{document}
\section{First section}
The first section begins here\ldots
\section{Second section}
The second section begins here\ldots
\end{document}
원하는 결과를 얻을 수 있는 방법을 누군가 설명해 주시면 매우 감사하겠습니다.
답변1
당신이 원하는 것이 이런 것입니까?
\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage[explicit]{titlesec}
\titleformat{\section}
[display]
{\filcenter
\Large\normalfont\sffamily\color{white}
}
{}
{0pt}
{\colorbox{RoyalBlue!80}{\parbox{\textwidth}{\centering\thesection\strut\\[1ex] #1\vskip 0.5ex}}}
\begin{document}
\section{First section}
The first section begins here\ldots
\section{Second section}
The second section begins here\ldots
\end{document}