3

is there a chance to use a small picture (like 60x25 px) as "numbering" for sections (or maybe as a item-marker in the item-environment?) An example of a picture is this one enter image description here.

Edit: I think one could use a itemize list for it, but I would like to customize the section "markers" to this picture. The same picture for each section. I don't need the number of the sections. I just want the picture to be on the left margin to indicate the beginning of a new section. Like a customization for \section*{New Topic}

Thank you in advance.

  • 1
    Welcome to TeX.SE. This is possible, but how does the picture change if the section number changes? (One thing to consider: A picture can't enter the bookmarks section of a pdf file, however). Changing \thesection is no good idea! – user31729 Apr 23 '17 at 21:28
  • 1
    Sure. That's easy. – Ulrike Fischer Apr 23 '17 at 21:29
  • In my case it's no necessary to use a toc, the picture doesn't need to change and the sections are more like a list of items. – Michael Schmid Apr 23 '17 at 21:35
  • @MichaelSchmid: A pure itemize list? – user31729 Apr 23 '17 at 21:37
  • 1
    You should take a look t the documentation of titlesec. – Bernard Apr 23 '17 at 21:46
6

A quick and dirty method for \section and all other section commands below that level is to redefine \@seccntformat to ignore the usual \csname the#1\endcsname and insert another command in there, which should be robust, however.

This could be basically anything, in the example I showed a quick tikz shaded ball, but an image can be included and scaled accordingly.

\documentclass{article}


\usepackage{graphicx}
\usepackage{tikz}

\DeclareRobustCommand{\picturetodisplay}{\includegraphics[scale=0.05]{ente}}

% Redefine it 
\DeclareRobustCommand{\picturetodisplay}{\begin{tikzpicture}\shade[ball color=blue] circle (1ex);\end{tikzpicture}}


\makeatletter
\def\@seccntformat#1{\picturetodisplay\quad}
\makeatother

\begin{document}

\section{A nice section}

\section{Another nice section}

\section{Yet another nice section}

\end{document}

enter image description here

Shifting the 'section number' to the margin:

\documentclass{article}

\usepackage{showframe}

\usepackage{graphicx}
\usepackage{tikz}

\newcommand{\unquad}{\hskip-1em\relax}

\DeclareRobustCommand{\picturetodisplay}{\begin{tikzpicture}\shade[ball color=blue] circle (1ex);\end{tikzpicture}}


\makeatletter
\def\@seccntformat#1{\unquad\unquad\picturetodisplay\quad}
\makeatother

\begin{document}

\section{A nice section}

\section{Another nice section}

\DeclareRobustCommand{\picturetodisplay}{\includegraphics[scale=0.03]{ente}}

\section{Yet another nice section}

\end{document}

enter image description here

| improve this answer | |
  • This way sections look like itemize lists – user31729 Apr 23 '17 at 22:11
  • And then I have to replace the text in the second {} of the redefinition to something like "/path/to/the/picture.jpg" ? – Michael Schmid Apr 23 '17 at 22:13
  • @MichaelSchmid: If you mean \includegraphics: Yes! The usual call is \includegraphics[some options]{path/to/the/picture.jpg], The options might be scaling, height, rotating even, if needed, but I don't recommend that in the section heading line – user31729 Apr 23 '17 at 22:18
  • Thank you very much! Do you have a idea how to make the text of the sections start at the beginning of the \textwidth-area? So the picture (section-marker) is in the left margin. – Michael Schmid Apr 23 '17 at 22:20
  • @MichaelSchmid: That's changing the question ;-) – user31729 Apr 23 '17 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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