当我用来生成带框的章节编号时,我想在下面的代码中提高章节标题的高度titlesec
,并与章节编号具有相同的高度:
这是 MWE:
\documentclass{book}
\usepackage{titlesec,tikz}
\titleformat{\section}
{\bfseries}
{ \begin{tikzpicture}
\node[
text width=1cm,
minimum height=1cm,
fill=red,
font=\color{white}\fontsize{20}{9}\sffamily,
align=center
] (num) {\thesection};
\end{tikzpicture}}
{12pt}
{\normalfont\LARGE\bfseries\scshape\color{red}}
\begin{document}
\setcounter{chapter}{1} % just to emulate a chapter has started
\section{One two three}
\end{document}