我有同样的问题: 如何在 ConTeXt 中创建具有“<title> <number>”格式的自定义章节标题?
但我想用 LaTeX 解决它。有没有一种简单的方法可以改编@phg 答案中的代码?
答案1
你可以使用 轻松按自己需要格式化titlesec
。以下是示例:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{fourier}
\usepackage{cabin}
\usepackage[x11names]{xcolor}
%
\usepackage[explicit]{titlesec}
\titleformat{\section}[hang]{\sffamily\color{IndianRed3}\bfseries\scshape\filleft\lsstyle}{}{2em}{#1\quad\rule[-0.25cm]{1.5pt}{1cm}\rlap{\qquad\Huge \thesection}}%
\setcounter{section}{3}
\begin{document}
\section{Tweedledum And Tweedledee}
They were standing under a tree, each with an arm round the other's neck, and Alice knew which was which in a moment, because one of them had 'DUM' embroidered on his collar, and the other 'DEE.' 'I suppose they've each got ”TWEEDLE” round at the back of the collar,' she said to herself.
They stood so still that she quite forgot they were alive, and she was just looking round to see if the word ”TWEEDLE” was written at the back of each collar, when she was startled by a voice coming from the one marked 'DUM.'
'If you think we're wax-works,' he said, 'you ought to pay, you know. Wax-works weren't made to be looked at for nothing, nohow!'
'Contrariwise,' added the one marked 'DEE,' 'if you think we're alive, you ought to speak.'
\end{document}