我正在尝试在文档(课程文章)中创建封面,并决定用盒子来“装饰”它。
这第一的我遇到的问题是,我不确定为什么标题出现在框的顶部而不是在中心。
这第二我的问题是,这个框和文档的边距一样大,而我希望它能够从一侧到另一侧覆盖页面(就像这篇文章末尾的图片一样)。
这第三问题是我想要多个框(每个框在页面上都有不同的颜色和空间),但我不确定如何在 latex 中制作多个框并在页面上随机排列它们。最后一张照片是封面,可以在 Word 中轻松制作。
如果您能为我提供除 tcolorbox 包手册之外的任何带有示例的资源,我将不胜感激。
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor} % to colour the front cover
\usepackage{afterpage} % needed to colour only front cover and no other page
\usepackage{graphicx} % to be able to embed graphical content
\usepackage{tcolorbox} % needed for the text boxes
\usepackage{color} % needed to recognise hex colour
\definecolor{pink}{HTML}{FDDBC7}
\definecolor{red}{HTML}{B2182B}
\definecolor{blue}{HTML}{4393C3}
% define boxes
%\%\%\%\%\ Title Box - box that will receive the title text
\makeatletter
\newcommand{\titlebox}[1]{%
\setbox0=\hbox{#1}%
\setlength{\@tempdima}{\dimexpr\wd0+13pt}%
\begin{tcolorbox}[ colframe=red, colback=red, boxrule=0.5pt, arc=0pt, % 90degrees corners
width=1\textwidth, height=0.5\textwidth, halign=flush center ] #1
\end{tcolorbox}
}
\makeatother
\title{An awsome report}
\author{An awsome person}
\makeindex
\title{An awsome report}
\author{An awsome person}
\makeindex
%graphicspath{{computer/folder/}} % for the inclusion of logos
\begin{document} % - - - - - - - - - - - - - - - - - - - - - - - - - -
% The title page
\makeatletter
\begin{titlepage}
\centering \titlebox{\huge\bfseries \@title \par}
\vspace{2cm}
{\Large \@author \par}
\begin{tcolorbox}
[colframe=white, colback=white, halign=flush center]
%\includegraphics[width=0.3\textwidth]{myawsomelogo1}%
\end{tcolorbox}
% color front cover and no other page
\pagecolor{pink}\afterpage{\nopagecolor}
\end{titlepage}
\makeatother
The rest of the document
\end{document}
可能的封面:
答案1
如果您想在页面上随机移动多个框,请使用 tikz。
\documentclass[12pt,a4paper]{article}
%\usepackage[utf8]{inputenc}% not with my editor
\usepackage{graphicx} % to be able to embed graphical content
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{color}
\definecolor{pink}{HTML}{FDDBC7}
\definecolor{red}{HTML}{B2182B}
\definecolor{blue}{HTML}{4393C3}
\newlength{\tempwidth}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[overlay,remember picture,font=\huge]
\node[below,minimum width={\paperwidth},minimum height={0.5\textwidth},
fill=red,text=white] at (current page.north) {An awesome report};
\node[minimum width={\paperwidth},minimum height={0.5\textwidth},
fill=red,text=white] at (current page.center) {An awesome person};
\node[above right,minimum width={0.5\paperwidth},minimum height={0.25\paperwidth},
draw=blue,line width=5mm,fill=red,text=white] at (current page.south west) {\today};
\node[above left,minimum width={0.5\paperwidth},minimum height={0.25\paperwidth},
draw=blue,line width=5mm,fill=red,text=white] at (current page.south east)
{\includegraphics[height=4cm]{example-image}};
\end{tikzpicture}
\newpage
The rest of the document
\end{document}
答案2
该软件包geometry
允许更改单个页面的边距。对于您的情况,可以将边距设置0pt
为标题页的边距。
例如,您可以执行以下操作来放置盒子:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor} % to colour the front cover
\usepackage{afterpage} % needed to colour only front cover and no other page
\usepackage{graphicx} % to be able to embed graphical content
\usepackage{tcolorbox} % needed for the text boxes
\usepackage{color} % needed to recognise hex colour
\usepackage{geometry}
\definecolor{pink}{HTML}{FDDBC7}
\definecolor{red}{HTML}{B2182B}
\definecolor{blue}{HTML}{4393C3}
\title{An awsome report}
\author{An awsome person}
\makeindex
\title{An awsome report}
\author{An awsome person}
\makeindex
\begin{document} % - - - - - - - - - - - - - - - - - - - - - - - - - -
% The title page
\newgeometry{margin=0pt}
\makeatletter
\begin{titlepage}
\centering
\begin{tcolorbox}[colframe=red,colback=red,sharp corners,halign=flush center,
valign=center,height=0.5\textwidth,fontupper=\Huge\bfseries,
after skip=2cm]
\@title
\end{tcolorbox}
{\Large \@author \par}
\begin{tcolorbox}[colframe=white,colback=white,halign=flush center,width=0.8\linewidth,
before skip=2cm]
My Logo
\end{tcolorbox}
\pagecolor{pink}\afterpage{\nopagecolor}
\end{titlepage}
\makeatother
\restoregeometry
The rest of the document
\end{document}