Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to modify the section command to make it look like this:

enter image description here

I wrote a tikz code for the decorated section number but I still don't know how to integrate my code in the \section command:

\newcommand*\numb{%
\begin{tikzpicture}
\node [rectangle,rounded corners,top color=black!80!gray!20, bottom color=black!80,text=white]{ \huge 1};
\end{tikzpicture}
}
share|improve this question

2 Answers 2

up vote 10 down vote accepted

One option, using the titlesec package and a variation of your \numb command:

\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}

enter image description here

share|improve this answer
    
Thank you it works (y) !! –  user45232 Feb 2 at 15:55

A slightly different solution also with titlesec, so that the section number be on the baseline:

\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} 

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.