如何在标题页上添加 tikz 图

如何在标题页上添加 tikz 图

我想添加这个情节阴谋(代码这里) 位于封面标题下方。

覆盖

我该怎么做?

这是该文件的来源。

\documentclass[10pt, twoside]{book} 
\usepackage{authblk}
    % Title, author and date
    \title{\Huge \textbf{Title}}
    \author{\textsc{John Doe}}
    \affil{Department of Mathematics}
    \date{2020}


    \begin{document}
    \frontmatter % Turns on roman numbering
    \maketitle
 \end{document}%

答案1

authblk样式似乎不是为此设计的。它\maketitle通过本地重新定义tabular环境来重新定义命令,使其成为center环境。可以利用这一点来放置图形。但是,由于authblk黑客攻击,\endcenter它会被执行两次,所以我们也需要注意这一点。

\documentclass[10pt, twoside]{book} 
\usepackage{authblk}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}%<- use a smaller version if you have an older installation
% Title, author and date
\title{\Huge \textbf{Title}}
\author{\textsc{John Doe}}
\affil{Department of Mathematics}
\date{2020}

\newsavebox\myplot
\sbox\myplot{\begin{tikzpicture}
\begin{axis}[trig format plots=rad,axis lines=left,
    xtick=\empty,ytick=\empty,domain=0:4,xmin=-0.5,
    xlabel=$n$,ylabel=$X_n$,
    xlabel style={at={(ticklabel cs:1,0)}},
    ylabel style={at={(ticklabel cs:1,0)},rotate=-90,anchor=west}]
\addplot[smooth,red,dashed,very thick] {1+exp(-x)};
\addplot[smooth,red,dashed,very thick] {1-exp(-x)};
\addplot[only marks,mark=*,color=blue!70!black,samples=151] {1+exp(-x)*sin(10*x)};
\end{axis}
\path (current bounding box.north) + (0,1); % add some vertical space
\end{tikzpicture}}

\begin{document}
\begingroup
\let\oldendcenter\endcenter
\edef\mypftflag{0}%
\def\endcenter{%
\xdef\mypftflag{\the\numexpr\mypftflag+1}%
\ifnum\mypftflag>1\relax
\usebox\myplot
\fi
\oldendcenter}
\frontmatter % Turns on roman numbering

\maketitle
\endgroup

\section{pft}
\end{document}%

在此处输入图片描述

相关内容