使用 tikz 的书籍类标题页

使用 tikz 的书籍类标题页

我正在尝试在图书课中设计标题页。我希望标题页看起来与所附图像完全一样。在 tikz 中创建矩形数组很容易。但是我在以下方面遇到了困难。

  1. 如何缩放或适合 tikz 图像以适应纸张的宽度和高度?
  2. 如何在矩形内嵌入文本?

虽然我经常使用 LaTeX,但我对 tikz 还是个新手。我还在考虑其他替代方案。例如,使用包含图形来包含图像,或者使用 pdfpages 包来包含单个 pdf 页面。但是,如果 tikz 本身就有这样的标题页就更好了。任何帮助都将不胜感激。谢谢。

在此处输入图片描述

答案1

使用简单的管状物和规则:

\documentclass{book}
\usepackage{libertinus}
\usepackage[svgnames,table]{xcolor}
\usepackage{tabularx}
\usepackage{url,ragged2e}
\renewcommand\tabularxcolumn[1]{m{#1}}
\usepackage{geometry}
\def\HUGE{\fontsize{1.6cm}{1.7cm}\selectfont}
\definecolor{ColA}{cmyk}{0.00,0.67,0.70,0.39}
\definecolor{ColB}{cmyk}{0.21,0.00,0.64,0.31}
\definecolor{ColC}{cmyk}{0.00,0.45,0.85,0.12}
\definecolor{ColD}{cmyk}{0.00,0.70,0.72,0.29}
\definecolor{ColE}{cmyk}{0.75,0.16,0.00,0.25}
\begin{document}

\begin{titlepage}
    \newgeometry{margin=0mm}
    \parindent=0pt\arrayrulecolor{white}\arrayrulewidth=1pt\tabcolsep=5pt
    \begin{tabularx}{\linewidth}{@{} X |X |X |X @{}}
        \multicolumn{4}{@{} c @{}}{%
            \cellcolor{ColA}\rule[-1cm]{0pt}{3cm}\bfseries\large
            \shortstack{\textcolor{white}{School of Mathematics}\\[1em] 
                \Large\textcolor{white}{XYZ University}}}\\\hline
        %
        \multicolumn{3}{@{} r| @{}}{%
            \cellcolor{ColB}\rule[-6cm]{0pt}{12cm}%
            \bfseries\textcolor{white}{\shortstack[l]{\HUGE Book Title\\[2cm]
                    \Large subtitle%
            }} \hspace*{1.5cm}}  & \cellcolor{ColC}\rule{\linewidth}{0pt}\\\hline
        %
        \rowcolor{ColA}%
        \rule{0pt}{2cm}  & & & \Centering\large\bfseries\textcolor{white}{Course code}\\\hline
        %
        \multicolumn{3}{@{} c| @{}}{%
            \cellcolor{ColD}\rule[-4.1cm]{0pt}{8.2cm}%
            \bfseries\large\shortstack[l]{Email: \url{[email protected]}\\[0.5cm]
                Website: \\[0.5cm]Phone: }}  & \cellcolor{ColE}\rule{\linewidth}{0pt}\\\hline
        %
        \multicolumn{4}{@{} l @{}}{%
            \cellcolor{ColA}\rule[-1cm]{0pt}{2.5cm} \large Address: }
    \end{tabularx}
\end{titlepage}
\restoregeometry

foo
\end{document}

在此处输入图片描述

答案2

这是给你一个开始。我不必完成它,但其余的只是重复。在矩形路径中嵌入文本的一种简单方法是node[midway]使用

 \draw[white,fill=bookred] (current page.north west) rectangle
        ++(\paperwidth,-4cm) node[midway,font=\Large\bfseries,align=center]
        {School of Mathematics\\[1em] XYZ University};

或者将其添加到矩形对角线的中间

 \path ([yshift=-18cm,xshift=0.75*\paperwidth]current page.north west)
     -- ++ (0.25\paperwidth,-2)  node[midway,white,font=\bfseries,scale=1.5] {Course
     code};

另一种方法是用 绘制一个节点node[draw,...]

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{positioning}
\definecolor{bookred}{RGB}{129, 57, 55}
\definecolor{bookredtop}{RGB}{204,61,57}
\definecolor{greentop}{RGB}{168, 197, 83}
\definecolor{greenbottom}{RGB}{128, 150, 64}
\definecolor{orangetop}{RGB}{230, 142, 54}
\definecolor{orangebottom}{RGB}{184, 110, 43}
\definecolor{bluetop}{RGB}{54,178,212}
\definecolor{bluebottom}{RGB}{39,137,162}

\begin{document}
\begin{tikzpicture}[overlay,remember picture,nodes={inner sep=0pt,outer sep=0pt}]
 \draw[white,fill=bookred] (current page.north west) rectangle
     ++(\paperwidth,-4cm) node[midway,font=\bfseries,align=center,scale=2]
     {School of Mathematics\\[0.5em] XYZ University};
 \draw[white,top color=greentop,bottom color=greenbottom] ([yshift=-4cm]current page.north west)
  rectangle   ++(0.75\paperwidth,-14cm);
 \draw[white,top color=orangetop,bottom color=orangebottom] ([yshift=-4cm]current
  page.north east) rectangle  ++(-0.25\paperwidth,-14cm);
 \draw[white,fill=bookred] ([yshift=-18cm]current page.north west)
  rectangle
     ++(\paperwidth,-2cm);   
 \node[scale=4,font=\bfseries,white] (title) at ([yshift=4cm]current page.center) {Book title};
 \node[scale=1.5,font=\bfseries,white,anchor=west]   at ([yshift=-2cm]title.west)
  {Subtitle};
 \draw[white]  foreach \X  in {0.25,0.5,0.75}  
  {([yshift=-18cm,xshift=\X*\paperwidth]current page.north west)
  -- ++(0,-2)} coordinate(aux);
 \path ([yshift=-18cm,xshift=0.75*\paperwidth]current page.north west)
  -- ++ (0.25\paperwidth,-2)  node[midway,white,font=\bfseries,scale=1.5] {Course
  code};
 \draw[white,fill=bookred] (current page.south west) rectangle
     ++(\paperwidth,2cm);
 \draw[white,bottom color=bookred,top color=bookredtop] 
  ([yshift=2cm]current page.south west) rectangle (aux);
 \draw[white,bottom color=bluebottom,top color=bluetop] 
  ([yshift=2cm]current page.south east) rectangle (aux);
 \path ([yshift=2cm]current page.south west) -- (aux) node[midway,above
  left=-4em and -2em,align=left,scale=1.5] {Email: abc@xyz\\[1em]
  Website: \\[1em] Phone: \\[1em]};
 \path ([yshift=1cm,xshift=1em]current page.south
  west)node[scale=1.5,white,anchor=west]{Address:};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容