![tikzpicture 作为章节标题,但文本在目录中](https://linux22.com/image/379266/tikzpicture%20%E4%BD%9C%E4%B8%BA%E7%AB%A0%E8%8A%82%E6%A0%87%E9%A2%98%EF%BC%8C%E4%BD%86%E6%96%87%E6%9C%AC%E5%9C%A8%E7%9B%AE%E5%BD%95%E4%B8%AD.png)
我想在 \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=
tikzpicture
0pt
我还对横幅命令进行了些许改进。使用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}