答案1
欢迎来到 TeX-SE!titlesec
允许您“破解”分段命令并使用 Ti钾Z 表示格式化。
\documentclass{article}
\usepackage{titlesec}
\usepackage{tikz}
\titleformat{\section}[hang]{\Large\sffamily}%
{\begin{tikzpicture}[baseline={([yshift=-1.5em]ts.north)}]
\draw[very thick,overlay] (0,0) -- (\textwidth,0);
\node[circle,fill=black,text=red,scale=2.5,anchor=west,outer sep=0pt] (ts) {\thesection};
\end{tikzpicture}}{12pt}{}%
\begin{document}
\section{Pft}
\section{Pfft}
\section{Pffft}
\end{document}
答案2
解决方案如下pstricks
:
\documentclass[svgnames]{article}
\usepackage{lipsum}
\usepackage{pstricks}
\usepackage{linegoal}
\usepackage{titlesec}
\titleformat{\section}[hang]{\sffamily}%
{\pscirclebox*[linecolor=DarkSlateGrey, fillcolor=DarkSlateGrey, framesep=14pt]{\Huge\textcolor{red}{\thesection}}%
\rlap{\color{DarkSlateGrey}\rule[6pt]{\linegoal}{1pt}}}%
{12pt}%
{\Large \color{DarkSlateGrey}\raisebox{12pt}}
\titlespacing*{\section}{0pt}{3mm}{5mm}
\begin{document}
\setcounter{section}{4}
\section{Discussion}
\lipsum[1]
\end{document}