我正在设计一个新的标题页以发布在主题中展示用 TeX 制作的精美标题页但我写的代码有些问题。我不喜欢,但我知道它可以改进。此外,我想给它添加一个小功能。我想在题词声明的正下方添加一条水平线(本质上是我设计的相同形状梯形的迷你版),并使用不同的不透明度,例如opacity=0.5
。这是 MWE:
\documentclass[letterpaper]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{epigraph}
\usepackage{lipsum}
\renewcommand\epigraphflush{flushleft}
\renewcommand\epigraphsize{\normalsize}
\setlength\epigraphwidth{0.7\textwidth}
\definecolor{titlepagecolor}{cmyk}{0.436,.865,0,.478}
\DeclareFixedFont{\titlefont}{T1}{ppl}{b}{it}{0.5in}
\makeatletter
\def\printauthor{%
{\large \@author}}
\makeatother
\author{%
Author 1 name \\
Department name \\
\texttt{[email protected]}\vspace{20pt} \\
Author 2 name \\
Department name \\
\texttt{[email protected]}
}
% This is the command I wish to optimize
\newcommand\titlepagedecoration[1]{%
\begin{tikzpicture}[remember picture,overlay,shorten >= -10pt]
\coordinate (tp1) at ([yshift=2cm]current page.west);
\coordinate (tp2) at ([yshift=2cm,xshift=9cm]current page.west);
\coordinate (tp3) at ([yshift=-15pt,xshift=7cm]current page.north);
\coordinate (tp4) at ([yshift=-15pt]current page.north west);
\filldraw[draw=titlepagecolor,fill=titlepagecolor] (tp1)--(tp2)--(tp3)--(tp4)--cycle;
\filldraw[draw=titlepagecolor!30!white,fill=titlepagecolor!30!white,opacity=0.2] ([xshift=-5cm]tp1)--([xshift=-5cm]tp2)--([xshift=-5cm]tp3)--([xshift=-5cm]tp4)--cycle;
\node[right] at ([xshift=1cm,yshift=-5cm]current page.north west) {\parbox{\textwidth}{\color{white}#1}};
\end{tikzpicture}%
}
\begin{document}
\begin{titlepage}
\titlepagedecoration{%
\titlefont Hardy's Theorem\par
\epigraph{Pure mathematics is on the whole distinctly more useful than applied. For what is useful above all is technique, and mathematical technique is taught mainly through pure mathematics.}%
{\textit{London 1941}\\ \textsc{G. H. Hardy}}
}
\null\vfill
\vspace*{1cm}
\noindent
\begin{minipage}{0.35\linewidth}
\begin{flushleft}
\printauthor
\end{flushleft}
\end{minipage}
\end{titlepage}
\lipsum[1-2]
\end{document}
请注意,我希望优化的部分是后台代码。
编辑
下面是我所追求的快速模型,几乎由 Henri Menke 实现:
答案1
我希望我理解正确。
\documentclass[letterpaper]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{epigraph}
\usepackage{lipsum}
\renewcommand\epigraphflush{flushleft}
\renewcommand\epigraphsize{\normalsize}
\setlength\epigraphwidth{0.7\textwidth}
\definecolor{titlepagecolor}{cmyk}{0.436,.865,0,.478}
\DeclareFixedFont{\titlefont}{T1}{ppl}{b}{it}{0.5in}
\makeatletter
\def\printauthor{%
{\large \@author}}
\makeatother
\author{%
Author 1 name \\
Department name \\
\texttt{[email protected]}\vspace{20pt} \\
Author 2 name \\
Department name \\
\texttt{[email protected]}
}
% This is the command I wish to optimize
\newcommand\titlepagedecoration[1]{%
\begin{tikzpicture}[remember picture,overlay,shorten >= -10pt]
\coordinate (tp1) at ([yshift=2cm]current page.west);
\coordinate (tp2) at ([yshift=2cm,xshift=9cm]current page.west);
\coordinate (tp3) at ([yshift=-15pt,xshift=7cm]current page.north);
\coordinate (tp4) at ([yshift=-15pt]current page.north west);
\filldraw[draw=titlepagecolor,fill=titlepagecolor] (tp1)--(tp2)--(tp3)--(tp4)--cycle;
\filldraw[draw=titlepagecolor!30!white,fill=titlepagecolor!30!white,opacity=0.2] ([xshift=-5cm]tp1)--([xshift=-5cm]tp2)--([xshift=-5cm]tp3)--([xshift=-5cm]tp4)--cycle;
\node[right] at ([xshift=1cm,yshift=-5cm]current page.north west) {\parbox{\textwidth}{\color{white}#1}};
\end{tikzpicture}%
}
\begin{document}
\begin{titlepage}
\titlepagedecoration{%
\titlefont Hardy's Theorem\par
\epigraph{Pure mathematics is on the whole distinctly more useful than applied. For what is useful above all is technique, and mathematical technique is taught mainly through pure mathematics.}%
{\textit{London 1941}\\ \textsc{G. H. Hardy}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% CHANGES HERE %%%%%%%%%%%%%%%%
\tikz[remember picture,overlay]{%
\node (X) {};
\filldraw[opacity=0.5,draw=titlepagecolor,fill=titlepagecolor] (tp1 |- X) -- (X -| tp2) -- (tp2) -- (tp1) -- cycle;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
\null\vfill
\vspace*{1cm}
\noindent
\begin{minipage}{0.35\linewidth}
\begin{flushleft}
\printauthor
\end{flushleft}
\end{minipage}
\end{titlepage}
\lipsum[1-2]
\end{document}
另一种可能性是
\documentclass[letterpaper]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{epigraph}
\usepackage{lipsum}
\renewcommand\epigraphflush{flushleft}
\renewcommand\epigraphsize{\normalsize}
\setlength\epigraphwidth{0.7\textwidth}
\definecolor{titlepagecolor}{cmyk}{0.436,.865,0,.478}
\DeclareFixedFont{\titlefont}{T1}{ppl}{b}{it}{0.5in}
\makeatletter
\def\printauthor{%
{\large \@author}}
\makeatother
\author{%
Author 1 name \\
Department name \\
\texttt{[email protected]}\vspace{20pt} \\
Author 2 name \\
Department name \\
\texttt{[email protected]}
}
% This is the command I wish to optimize
\newcommand\titlepagedecoration[1]{%
\begin{tikzpicture}[remember picture,overlay,shorten >= -10pt]
\coordinate (tp1) at ([yshift=2cm]current page.west);
\coordinate (tp2) at ([yshift=2cm,xshift=9cm]current page.west);
\coordinate (tp3) at ([yshift=-15pt,xshift=7cm]current page.north);
\coordinate (tp4) at ([yshift=-15pt]current page.north west);
\filldraw[draw=titlepagecolor,fill=titlepagecolor] (tp1)--(tp2)--(tp3)--(tp4)--cycle;
\filldraw[draw=titlepagecolor!30!white,fill=titlepagecolor!30!white,opacity=0.2] ([xshift=-5cm]tp1)--([xshift=-5cm]tp2)--([xshift=-5cm]tp3)--([xshift=-5cm]tp4)--cycle;
\node[right] at ([xshift=1cm,yshift=-5cm]current page.north west) {\parbox{\textwidth}{\color{white}#1}};
\end{tikzpicture}%
}
\begin{document}
\begin{titlepage}
\titlepagedecoration{%
\titlefont Hardy's Theorem\par
\epigraph{Pure mathematics is on the whole distinctly more useful than applied. For what is useful above all is technique, and mathematical technique is taught mainly through pure mathematics.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% CHANGES HERE %%%%%%%%%%%%%%%%
\tikz[remember picture,overlay]{%
\node (X) at (0,-1ex) {};
\filldraw[opacity=0.5,draw=titlepagecolor,fill=titlepagecolor] (tp1 |- X) -- (X -| tp2) -- (tp2) -- (tp1) -- cycle;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}%
{\textit{London 1941}\\ \textsc{G. H. Hardy}}
}
\null\vfill
\vspace*{1cm}
\noindent
\begin{minipage}{0.35\linewidth}
\begin{flushleft}
\printauthor
\end{flushleft}
\end{minipage}
\end{titlepage}
\lipsum[1-2]
\end{document}
我根据您的编辑更新了我的答案:
\documentclass[letterpaper]{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{epigraph}
\usepackage{lipsum}
\renewcommand\epigraphflush{flushleft}
\renewcommand\epigraphsize{\normalsize}
\setlength\epigraphwidth{0.7\textwidth}
\definecolor{titlepagecolor}{cmyk}{0.436,.865,0,.478}
\DeclareFixedFont{\titlefont}{T1}{ppl}{b}{it}{0.5in}
\makeatletter
\def\printauthor{%
{\large \@author}}
\makeatother
\author{%
Author 1 name \\
Department name \\
\texttt{[email protected]}\vspace{20pt} \\
Author 2 name \\
Department name \\
\texttt{[email protected]}
}
% This is the command I wish to optimize
\newcommand\titlepagedecoration[1]{%
\begin{tikzpicture}[remember picture,overlay,shorten >= -10pt]
\coordinate (tp1) at ([yshift=2cm]current page.west);
\coordinate (tp2) at ([yshift=2cm,xshift=9cm]current page.west);
\coordinate (tp3) at ([yshift=-15pt,xshift=7cm]current page.north);
\coordinate (tp4) at ([yshift=-15pt]current page.north west);
% Place text to het its coordinates
\node[right] (titletext) at ([xshift=1cm,yshift=-5cm]current page.north west) {\parbox{\textwidth}{\color{white}#1}};
\path[name path=p1] ([xshift=-5cm]tp2) -- ([xshift=-5cm]tp3);
\path[name path=p2] (tp2) -- (tp3);
\path[name path=p3] (tp1 |- titletext.south) -- (titletext.south -| tp3);
\path[name intersections={of=p1 and p3,name=first}];
\path[name intersections={of=p2 and p3,name=second}];
\filldraw[titlepagecolor!100!white] (first-1) -- (second-1) -- (tp3) -- ([xshift=-5cm]tp3) -- cycle;
\filldraw[titlepagecolor!80!white] (tp4) -- ([xshift=-5cm]tp3) -- (first-1) -- (tp1 |- titletext.south) -- cycle;
\filldraw[titlepagecolor!100!white] (tp1 |- titletext.south) -- (first-1) -- ([xshift=-5cm]tp2) -- (tp1) -- cycle;
\filldraw[titlepagecolor!80!white] (first-1) -- (second-1) -- (tp2) -- ([xshift=-5cm]tp2) -- cycle;
% Place text again, to have it on top
\node[right] (titletext) at ([xshift=1cm,yshift=-5cm]current page.north west) {\parbox{\textwidth}{\color{white}#1}};
\end{tikzpicture}%
}
\begin{document}
\begin{titlepage}
\titlepagedecoration{%
\titlefont Hardy's Theorem\par
\epigraph{Pure mathematics is on the whole distinctly more useful than applied. For what is useful above all is technique, and mathematical technique is taught mainly through pure mathematics.}%
{\textit{London 1941}\\ \textsc{G. H. Hardy}}
}
\null\vfill
\vspace*{1cm}
\noindent
\begin{minipage}{0.35\linewidth}
\begin{flushleft}
\printauthor
\end{flushleft}
\end{minipage}
\end{titlepage}
\lipsum[1-2]
\end{document}