2

I want to use a little banner as title in \section. It should look like the banner above "vocabulaire" but the text doesn't change its size and I would like to get rid of the section numbering. My second problem is that I want the banner to appear in the body of the document but not in the table of contents. Is it possible to have only the date there?

\documentclass[12pt]{article}

\usepackage[ngerman]{babel}
\usepackage[a4paper, text={16.5cm, 25.2cm}, centering]{geometry}
\usepackage[sfdefault]{ClearSans}
\usepackage[utf8]{inputenc}
\setlength{\parskip}{1.2ex}
\setlength{\parindent}{0em}


\usepackage{tikz}
\usetikzlibrary{shapes.symbols,shadows}

\definecolor{bancolor}{RGB}{62,96,111}


 \DeclareRobustCommand\datebanner[2]{\begin{tikzpicture}
\node[
  signal,
  signal from=north,
  signal pointer angle=150,
  fill=bancolor!75,
  drop shadow={shadow xshift=0pt, color=bancolor},
  rotate=-90,
  text width=2cm,
  text height=1.5cm,
  anchor=north west
  ] (banner) at (0,0) {};
% the text in the banner
\node[
  anchor=south,
  text width=3cm,
  align=center,
  font=\itshape] 
  at ([yshift=1cm]banner.east) {#1 \\ #2};
\end{tikzpicture}}

\begin{document}

\tableofcontents

\section{\datebanner{2. April}{2018}}


\vspace{64pt}

\begin{tikzpicture}
\node[
  signal,
  signal from=north,
  signal pointer angle=150,
  fill=bancolor!75,
  drop shadow={shadow xshift=0pt, color=bancolor},
  rotate=-90,
  text width=2cm,
  text height=1.5cm,
  anchor=north west
  ] (banner) at (0,0) {};
% the text in the banner
\node[
  anchor=south,
  text width=3cm,
  align=center,
  font=\itshape] 
  at ([yshift=1cm]banner.east) {28. April \\ 2018};
\end{tikzpicture}

\subsection{Vocabulaire}

\subsection{film}


\subsection{grammaire}

\subsubsection{Si + ...}

\subsection{orthographie}

\end{document}

So far it looks like this

enter image description here

  • 2
    Are all \sections like this? I.e., do you want to hide the numbering of all the \sections? For the second part, \section[2. April 2018]{\datebanner{2. April}{2018}}. The optional argument to \section is used to define an alternative text for the ToC. – Torbjørn T. Jul 11 '18 at 21:07
  • Thank you, that solved the ToC problem. Yes all \section are like this. How do I prevent the text in the banner to change it size? – Katharina Jul 11 '18 at 21:59
  • 1
    So no section number in the text. Next question: should there be a section number in the table of contents? Next piece of the puzzle: you can replace font=\itshape with font=\normalsize\itshape to overwrite the font size set by \section. – Mike Jul 11 '18 at 22:08
  • Yes, section number should be in the table of contents. – Katharina Jul 11 '18 at 22:26
1

This uses the titlesec package to format the section title. The font is set to the default in \titleformat (second argument), which is overwritten with font= in the tikzpicture. Otherwise, the title of the table of contents would be in italic too. The fourth argument sets the distance between the label and the title. Since the label, i.e. the section number, is left empty (fourth argument), 0pt puts the banner at the left.

I also took the freedom to improve your banner command a bit. Using minimum width instead of text width ensures, that the banner adapts to the text, if it is wider.

enter image description here

The code:

\documentclass[12pt]{article}

\usepackage[ngerman]{babel}
\usepackage[a4paper, text={16.5cm, 25.2cm}, centering]{geometry}
%\usepackage[sfdefault]{ClearSans}
\usepackage[utf8]{inputenc}
\setlength{\parskip}{1.2ex}
\setlength{\parindent}{0em}

%added
\usepackage{titlesec}
\titleformat{\section}{\Large\bfseries}{}{0pt}{}{}


\usepackage{tikz}
\usetikzlibrary{shapes.symbols,shadows}

\definecolor{bancolor}{RGB}{62,96,111}

% changed, only one argument now
\DeclareRobustCommand\datebanner[1]{\begin{tikzpicture}
\node[
  signal,
  signal to=south,
  signal pointer angle=150,
  fill=bancolor!75,
  drop shadow={shadow xshift=0pt, color=bancolor},
  minimum width=2.5cm,
  minimum height=3cm,
  align=center,
  font=\normalsize\itshape
  ] (banner) at (0,0) {#1};
\end{tikzpicture}}

\begin{document}

\tableofcontents

\section[1. Mai 2018]{\datebanner{1. Mai\\2018}}

\section[2. April 2018]{\datebanner{2. April\\2018}}

\section[27. September 2018]{\datebanner{27. September\\2018}}


\subsection{Vocabulaire}

\subsection{film}


\subsection{grammaire}

\subsubsection{Si + ...}

%\subsection{orthographie}

\end{document}

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.