tikzpicture 作为章节标题,但文本在目录中

tikzpicture 作为章节标题,但文本在目录中

我想在 \section 中使用一个小横幅作为标题。它应该看起来像“vocabulaire”上方的横幅,但文本不会改变其大小,我想去掉部分编号。我的第二个问题是,我希望横幅出现在文档正文中,而不是目录中。是否可以只在那里显示日期?

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

到目前为止它看起来像这样

在此处输入图片描述

答案1

这将使用titlesec包来格式化章节标题。在(第二个参数)中将字体设置为默认字体,在 中用\titleformat覆盖。否则,目录的标题也将是斜体。第四个参数设置标签和标题之间的距离。由于标签(即章节编号)留空(第四个参数),因此将横幅放在左侧。font=tikzpicture0pt

我还对横幅命令进行了些许改进。使用minimum width代替text width可确保横幅适应文本(如果文本较宽)。

在此处输入图片描述

代码:

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

相关内容