我想修改部分命令,使其看起来像这样:
我为装饰部分编号编写了一个 tikz 代码,但我仍然不知道如何在命令中集成我的代码\section
:
\newcommand*\numb{%
\begin{tikzpicture}
\node [rectangle,rounded corners,top color=black!80!gray!20, bottom color=black!80,text=white]{ \huge 1};
\end{tikzpicture}
}
答案1
一个选项是使用titlesec
包和命令的变体 \numb
:
\documentclass{article}
\usepackage{titlesec}
\usepackage{tikz}
\newcommand*\numb[1]{%
\begin{tikzpicture}[baseline=-1.4ex]
\node[
rectangle,
rounded corners=2pt,
top color=black!15,
bottom color=black!90,
text=white,
inner ysep=0pt,
text height=3ex,
text depth=0.45ex]
{\parbox{0.7cm}{\raggedleft\huge#1}};
\end{tikzpicture}%
}
\titleformat{\section}
{\normalfont\Large\bfseries\sffamily}{\numb{\thesection}}{1em}{}
\begin{document}
\section{A test section}
\section{Another test section}
\section*{An unnumbered section}
\end{document}
答案2
与 titlesec 略有不同的解决方案是,使章节编号位于基线上:
\documentclass[12pt]{amsproc}% http://ctan.org/pkg/amsproc
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\newcommand*\numb[1]{%
\begin{tikzpicture}
\node [rectangle,rounded corners,top color=black!80!gray!20, bottom color=black! 80,text=white]{ \huge #1};
\end{tikzpicture}
}%
\usepackage{titlesec}
\titleformat{\section}[block]{\bfseries\large}{\raisebox{-5.4pt}{\numb{\arabic{section}}}}{0.4em}{}
\begin{document}
\section{Fonctions homlomorphes}\label{sec:prelim}
Première section
\section{Another section}
Voir Section~\ref{sec:prelim}.
\end{document}