制作首页模板

制作首页模板

我用 LaTeX 制作了一个首页,现在的样子让我很满意。但是,我想优化我的代码,这样每次我只需要更改文本即可。更具体地说,我希望标题位于蓝色框的底部,如果很长,则分成两行(最好第二行最长)。此外,我希望右侧的 Tikzpicture 标题保持在那里,而不受标题长度的影响。“Logo”图片也是如此。

另外,是否可以在序言中定义“title”、“leadparagraph”、“seriesnumber”、“author”等?这样更容易随时更改。

我对 LaTeX 还很陌生,感谢大家的帮助。

这是我的代码:

\documentclass[a4paper, 12pt, svgnames]{article}
\usepackage{tcolorbox, graphicx, standalone, mathptmx, tikz}
\pagestyle{empty}
\usepackage[utf8]{inputenc}
\usepackage[left=0.6in, right=0.6in, top=0.6in, bottom=0.6in]{geometry}

\begin{document}

\begin{tcolorbox}[colback=NavyBlue, colframe=NavyBlue, height=6.2in, sharpish corners]
\begin{minipage}{4.5in}
\vspace{5.2in}
\begin{flushleft}
{\bfseries\color{white}\fontsize{35}{42}\selectfont Title (Sometimes Over Two Lines) }
\end{flushleft}
\end{minipage}
\begin{minipage}{2in}
\vspace{5.2in}
\begin{flushright}
\begin{tikzpicture}[smooth cycle, line width=6pt, scale=1]
\draw[line join=miter, color=Gold]  (0,0) -- ++ (0.7,-0.5) -- ++ (0.7,0.5);
\draw[line join=miter, color=brown]  (0,-0.4) -- ++ (0.7,-0.5) -- ++ (0.7,0.5);
\draw[line join=miter, color=red]  (0,-0.8) -- ++ (0.7,-0.5) -- ++ (0.7,0.5);

\end{tikzpicture}
\end{flushright}
\end{minipage}
\end{tcolorbox}
\vspace{-0.1in} 
\begin{tcolorbox}[colback=AliceBlue, colframe=AliceBlue, height=3.8in, sharpish corners]
\begin{minipage}{2.7in}
\vspace{2.18in}
\begin{flushright}
\textit{Name of Author\\\vspace{10pt}
Department\\
University}
\end{flushright}
\vspace{0.1in}
\begin{tikzpicture}
\draw[fill=NavyBlue] (0,0) -- (0,0.5) -- (4,0.5) --(4,0) -- (0,0);
\draw (2, 0.23) node{\color{AliceBlue}LOGO};        
\end{tikzpicture}   
\end{minipage}
\hspace{0.25in}
\begin{minipage}{3.5in}
\textbf{\Large Series number xx/xx}
\vspace{12pt}

        Here goes the lead paragraph. Usually not more than 7-8 lines. 
        Here goes the lead paragraph. Usually not more than 7-8 lines. 
        Here goes the lead paragraph. Usually not more than 7-8 lines. 
        Here goes the lead paragraph. Usually not more than 7-8 lines. 
        Here goes the lead paragraph. Usually not more than 7-8 lines.
\vspace{1.7in}
\end{minipage}
\end{tcolorbox} 

\end{document}

它看起来是这样的在此处输入图片描述

答案1

我已经在 Tikz 中从头重建了您的代码(但使用了您的颜色、字体大小等)。在某些情况下,代码更短且更易于维护。位置上存在很小的差异,但我已尝试尽可能接近地复制您自己的代码。

我把所有内容包装在一个\mytitlepage带有 5 个参数的新命令中:

\mytitlepage{ <title> }{ <serial> }{ <text> }{ <author> }{ <dept> }

对于序列号,只需要数字,“序列号”部分已打印。无论标题的长度如何,箭头都会停留在原处。

我不确定您是否可以自动换行以使第二行更长,但这可以通过应用\\您希望新行开始的位置轻松解决。

输出

在此处输入图片描述

代码

\documentclass[a4paper, 12pt, svgnames]{article}
\usepackage{mathptmx, tikz}
\usepackage{varwidth}
\usepackage[utf8]{inputenc}
\usepackage[left=0.6in, right=0.6in, top=0.6in, bottom=0.6in]{geometry}

\usetikzlibrary{calc}

\newcommand\mytitlepage[5]{%
\noindent
\begin{tikzpicture}[overlay,remember picture, 
    shift={($(current page.south west)+(.6in,.6in)$)}
    ]
% Background
\fill[NavyBlue] ($(current page.west)+(.6in,-2cm)$) rectangle
    ($(current page.north east)+(-.6in,-.6in)$);
\fill[AliceBlue] ($(current page.west)+(.6in,-2cm)$) rectangle
    ($(current page.south east)+(-.6in,.6in)$);
% Dark blue section
\node[text=white, font=\bfseries, text width=9cm, anchor=south west, outer xsep=5mm,outer ysep=1mm] 
    at ($(current page.west)+(.6in,-2cm)$) 
    {\fontsize{35}{42}\selectfont #1};
\begin{scope}[smooth cycle, line width=6pt, scale=1, shift={($(current page.east)+(-4cm,-2mm)$)}]
\draw[line join=miter, color=Gold]  (0,0) -- ++ (0.7,-0.5) -- ++ (0.7,0.5);
\draw[line join=miter, color=brown]  (0,-0.4) -- ++ (0.7,-0.5) -- ++ (0.7,0.5);
\draw[line join=miter, color=red]  (0,-0.8) -- ++ (0.7,-0.5) -- ++ (0.7,0.5);
\end{scope}
% Light blue section
\node[font=\bfseries\Large, anchor=north west, outer ysep=2mm] (sn) at ($(current page)+(-1cm,-2cm)$) {Serial Number #2};
\node[anchor=north west, outer ysep=2mm] (text) at (sn.south west) {\begin{varwidth}{8cm}#3\end{varwidth}};
\node[anchor=east, yshift=-6cm, xshift=-6mm, font=\itshape, align=right] at (sn.south west) {#4};
\node[anchor=east, text width=2cm, font=\itshape, yshift=-7.5cm, xshift=-6mm, align=right] at (sn.south west) {#5};
\node[fill=NavyBlue, text=AliceBlue, 
    anchor=south west, align=center, text width=4cm] at (.5,.5) {LOGO};
\end{tikzpicture}   
}

\begin{document}

\mytitlepage{Super mega\\ultra long Title}{555/2368}{Here goes the lead paragraph. Usually not more than 7-8 lines. Here goes the lead paragraph. Usually not more than 7-8 lines. Here goes the lead paragraph. Usually not more than 7-8 lines. Here goes the lead paragraph. Usually not more than 7-8 lines. Here goes the lead paragraph. Usually not more than 7-8 lines. Here goes the lead paragraph. Usually not more than 7-8 lines.}{John Doe}{Some\\Department}
\end{document}

相关内容