0

I've just defines a new type of section title following this page. The used code is shown below:

\newcommand{\ssection}[1]{%
  \section[#1]{\centering\Large \\ #1}}

If I type \ssection{This is a test} I get the following result:

enter image description here

What I want to do is:

  1. (Mandatory) Remove the dot after the section number.
  2. (Optional) Make some fancy thing with the number, like put it inside a circle maybe.

Thanks you very much in advance.

EDIT:

I add a MWE:

\documentclass[a4paper, 12pt, oneside]{article}

\usepackage[spanish,es-tabla]{babel}

\newcommand{\ssection}[1]{%
  \section[#1]{\centering\Large \\ #1}}
  
  \begin{document}
  \ssection{This is a test}
  \end{document}

I've just realized that removing \usepackage[spanish,es-tabla]{babel} the problem is solved, but I need that dot in subsections, subsubsections and so on.

4
  • There is no dot with standard classes. The output is due to code you are withholding. Please post a MWE.
    – campa
    May 19, 2022 at 15:53
  • Added. Thanks you @campa May 19, 2022 at 16:02
  • Have you considered not defining \ssection, but just using \section and changing how the titles are formatted using the titlesec package? Your solution would mess up the table of contents and PDF bookmarks if you were using them.
    – frabjous
    May 19, 2022 at 18:09
  • I didn't know that could was a problem... Thanks for your advice frabjous. May 20, 2022 at 10:10

1 Answer 1

1

I have this idea to achieve that. But it end up with shifting the star version section heading down as well (As I labeled in figure with red rectangle). You can always add local titleformat to avoid it (e.g. add another titleformat define before \tableofcontents). But this seems to be a little complicated. Maybe somebody have better solution.

\documentclass[a4paper, 12pt, oneside]{article}
\usepackage{showframe}
\usepackage{tikz}
\usepackage[spanish,es-tabla]{babel}
\usepackage{titlesec}
\titleformat{\section}%
{\centering\normalfont\Large\bfseries}%
{\tikz\node[line width=2pt,circle,draw=red,fill=red!20]{\thesection};}%
{0pt}%
{\mbox{}\\}%
{}

\begin{document}
\tableofcontents
\clearpage
\section{This is a test}
\subsection{this is test}
\subsubsection{this is test}
\end{document}

enter image description here enter image description here

1
  • Thanks Tom! This is a goos solution for my case, really. Shifting the star version is a minor consequence that I can dodge. May 20, 2022 at 10:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .