我希望能够创建如下页面:
顺便说一下,我正在使用 PDFLaTeX。
我尝试过各种minipage
环境,但每次我有所成就,总会遇到问题。我的计划是创建两个小页面,一个是灰色背景,一个是黑色背景,然后在需要的地方添加文本和图片。我意识到封面不需要用 LaTeX,但此时,在我花了这么多时间尝试实现它之后,我只想在纸上看到它。我遇到了各种各样的问题:无法将图片居中,无法容纳图片,标题页被推到第 2 页,还有其他一些问题。
我想知道是否有人能给出一些明智的建议或实用的建议来帮助我实现我的目标。
或者,我很乐意使用通过 paint.net 创建的页面,并将其作为图片附加,然后将其导入我的 LaTeX 标题页。但是,即使这样做,我也遇到了很多麻烦,它看起来总是不像我想要的那样。
提前感谢您的任何善举……
莫里斯
我的“代码”是
\documentclass[10pt]{book}
\usepackage{color}
\usepackage{xcolor}
\begin{document}
\pagestyle{empty}
\begin{titlepage}
\colorbox{gray}{\begin{minipage}[t]{0.15\textwidth}
\offinterlineskip
\begin{center}
\includegraphics[scale=0.40]{Doob_4a.jpg} \\
..........................
\includegraphics[scale=0.40]{Poisson_4a.jpg}\\
\end{center}
\end{minipage}}
\colorbox{black}{\begin{minipage}[t]{0.85\textwidth}
\begin{center}
\vbox{ \hbox{{\huge {\bf \textcolor{white}{PROBABILITY THEORY}}}}
\vskip 10pt \noindent
\hbox{{\Large{\bf \textcolor{white}{A Modern Comprehensive Course}}}}
}
\vskip .25cm \noindent
\textcolor{white}{\hrule}
\textcolor{white}{\hrule}
\vskip .5cm \noindent
{\large \textcolor{white}{XXXXX YYYYYY}}
\vskip 2.75cm
\includegraphics[scale=0.70]{BM3d.png}
\vskip 2.5cm
{\large \textcolor{white}{Occult Sciences Publishing}}
\end{center}
\end{minipage}}
\end{titlepage}
\end{document}
我的问题是:
- 标题页被推到第 2 页;
- 小页面不均匀;并且
- 理想情况下,我还希望灰色和黑色之间没有任何空格...看起来仍然不太好,但至少是可行的。
答案1
类似这样?请注意,左侧的图像并非都具有相同的宽度,因为我使用的图像的比例不同。只要您的图像具有相同的高度:宽度比,它们的宽度就会匹配。
\documentclass[letterpaper]{article}
\usepackage[scale=1]{geometry}
\usepackage{tikz,calc}
\usetikzlibrary{positioning,calc}
\setlength\parindent{0pt}
\begin{document}
\begin{tikzpicture}
\fill [black] (current page.north east) rectangle (current page.south west);
\fill [gray] (current page.north west) rectangle ([xshift=50mm]current page.south west);
\node (person 0) [anchor=south, inner sep=0pt] at ([xshift=25mm,yshift=-10mm]current page.north west) {};
\foreach \i [count=\ino, remember=\ino as \j (initially 0)] in {example-image-9x16,example-image-golden-upright,example-image-9x16,example-image-golden-upright,example-image-9x16,example-image-golden-upright,example-image-9x16,example-image-golden-upright,example-image-9x16,example-image-golden-upright,example-image-9x16,example-image-golden-upright,example-image-9x16}
\node (person \ino) [anchor=north, inner sep=0pt] at (person \j.south) {\includegraphics[height=\paperheight/13-20mm/13] {\i} };
\node (title) [anchor=south, font=\Huge\bfseries, text=white] at ([xshift=25mm,yshift=-50mm]current page.north) {PROBABILITY THEORY};
\node (subtitle) [below=5mm of title.south, anchor=north, text=white, font=\LARGE\bfseries] {A Modern Comprehensive Course};
\path [line width=1pt, draw=white] ([yshift=-5mm]title.west |- subtitle.south) coordinate (a) -- ([yshift=-5mm]title.east |- subtitle.south) coordinate (b) ([xshift=2.5mm,yshift=-2.5mm]a) -- ([xshift=-2.5mm,yshift=-2.5mm]b) coordinate (c);
\node at ($(title.center |- c)!1/2!(current page.south -| title.center)$) {\includegraphics[height=.5\paperheight] {tiger}};
\end{tikzpicture}
\end{document}
使用
\usepackage{pdfpages}
...
\includepdf{<filename>}
如果您希望将其包含在主文档中。(这看起来很奇怪,因为它可能不应该被编号。但如果您需要它,您可以这样做。)
编辑
我最初尝试只使用标准 TeX 发行版中的图像。既然没有其他人会限制自己这样做,我想我也可以尝试一下。这是一个更依赖参数来设置封面的版本。基本代码是相同的。唯一的区别实际上是某些设置不再是硬编码的。可能对封面没什么用,但在可能使用具有相同结构的多张图片的类似情况下可能很方便。
不过,我会保留老虎。无论是否是标准……
\documentclass[letterpaper]{article}
\usepackage[scale=1]{geometry}
\usepackage{tikz,calc}
\usetikzlibrary{positioning,calc}
\setlength\parindent{0pt}
\newlength\coverscratch
\setlength\coverscratch{10mm}
\newlength\coverborder
\setlength\coverborder{30mm}
\tikzset{%
cover border left/.store in=\coverborderleft,
cover border right/.store in=\coverborderright,
cover border top/.store in=\coverbordertop,
cover border bottom/.store in=\coverborderbottom,
cover border images/.store in=\coverborderimages,
cover sample image/.code={%
\settowidth{\coverscratch}{\includegraphics[height=\paperheight/\coverborderimages-\coverbordertop/\coverborderimages-\coverborderbottom/\coverborderimages]{#1}}%
\setlength{\coverborder}{\coverborderleft+\coverborderright+\coverscratch}%
},
cover border image/.style={%
anchor=north,
inner sep=0pt,
node contents={\includegraphics[height=\paperheight/\coverborderimages-\coverbordertop/\coverborderimages-\coverborderbottom/\coverborderimages]{#1}},
},
cover title drop/.store in=\covertitledrop,
% make sure everything has a default
cover border left=10mm,
cover border right=10mm,
cover border top=2.5mm,
cover border bottom=2.5mm,
cover border images=13,
cover sample image={example-image-golden-upright},
cover title drop=50mm,
}
\begin{document}
\begin{tikzpicture}
[
cover border top=5mm,
cover border bottom=5mm,
cover border left=7.5mm,
cover border right=7.5mm,
cover sample image={people/Charles_Darwin},% best to set this last to ensure correct values are used
]
\fill [black] (current page.north east) rectangle (current page.south west);
\fill [gray] (current page.north west) rectangle ([xshift=\coverborder]current page.south west);
\node (person 0) [anchor=south, inner sep=0pt] at ([xshift=.5*\coverborder,yshift=-\coverbordertop]current page.north west) {};
\foreach \i [count=\ino, remember=\ino as \j (initially 0)] in {Albert_Einstein,Carl_Sagan,Charles_Darwin,Marie_Curie,Niels_Bohr,Nikola_Tesla,Richard_Feynman,Steven_Hawking,Stimpson_J,Albert_Einstein,Carl_Sagan,Charles_Darwin,Marie_Curie}
\node (person \ino) at (person \j.south) [cover border image={people/\i}];
\node (title) [anchor=south, font=\Huge\bfseries, text=white] at ([xshift=.5*\coverborder,yshift=-\covertitledrop]current page.north) {PROBABILITY THEORY};
\node (subtitle) [below=5mm of title.south, anchor=north, text=white, font=\LARGE\bfseries] {A Modern Comprehensive Course};
\path [line width=1pt, draw=white] ([yshift=-5mm]title.west |- subtitle.south) coordinate (a) -- ([yshift=-5mm]title.east |- subtitle.south) coordinate (b) ([xshift=2.5mm,yshift=-2.5mm]a) -- ([xshift=-2.5mm,yshift=-2.5mm]b) coordinate (c);
\node at ($(title.center |- c)!1/2!(current page.south -| title.center)$) {\includegraphics[height=.5\paperheight] {tiger}};
\end{tikzpicture}
\end{document}
答案2
您也可以尝试文本位置-package。它有一个很好的手册,而且很容易学习,即使你通过反复试验来学习。如果你像我一样不熟练Tikz
,也许你会发现textpos
更容易使用。
我已经制作了封面,但您必须链接到自己的文件。也许您应该在外部程序中协调所有图片的高度和宽度,而keepaspectratio=true
不是使用明确的宽度(我固定了高度和宽度只是为了节省时间)。如您所见,我制作了一个由十三个垂直模块和十二个水平模块组成的网格。为了在脸部周围留出边框,我稍微降低了图片的高度。现在每个人的照片都占据一个垂直模块,少了几毫米。
您还会发现,我将深灰色和黑色背景创建为占据整个页面的框。使用网格模块可以轻松更改纸张大小,因为网格是相对于页面高度和宽度设置的。此后,您只需将两个“背景”框与包含文本和图形的新框叠加即可。texpos
兼容,calc
因此也很容易计算相对位置。
\documentclass{book}
\usepackage[absolute]{textpos}
\usepackage{calc,color,xcolor,graphicx}
\TPGrid[0mm,0mm]{12}{13}
\textblockorigin{0mm}{0mm} % start everything near the top-left corner
\setlength{\parindent}{0pt}
\begin{document}
\begin{textblock}{2}(0,0)
\textblockcolour{darkgray}
\parbox[0][13\TPVertModule][0]{2\TPHorizModule}{text}
\end{textblock}
\begin{textblock}{10}(2,0)
\textblocklabel{block two}
\textblockcolour{black}
\parbox[0][13\TPVertModule][0]{10\TPHorizModule}{text}
\end{textblock}
\begin{textblock}{8}[0.5,0.5](7,2)
\textblockcolour{black}
\centering\textcolor{white}{\Huge\bfseries PROBABILITY THEORY}\par\bigskip
\textcolor{white}{\huge A Modern Comprehensive Course}\par\medskip
\textcolor{white}{\rule{6.5\TPHorizModule}{1pt}}\par\vspace{-0.5\baselineskip}
\textcolor{white}{\rule{6.5\TPHorizModule}{1pt}}
\end{textblock}
\begin{textblock}{1.5}(0.4,0.1)
\textblockcolour{darkgray}
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{homer-simpson}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{Marge_Simpson}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{lisa-simpson}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{Apu}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{barney-gumble}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{homer-simpson}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{Marge_Simpson}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{lisa-simpson}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{Apu}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{barney-gumble}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{homer-simpson}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{Marge_Simpson}\par
\includegraphics[width=1.5\TPHorizModule, height=1\TPVertModule-0.65mm]{lisa-simpson}\par
\end{textblock}
\begin{textblock}{8}[0.5,0.5](7,7)
\textblockcolour{black}
\centering
\includegraphics[width=1.5\TPHorizModule, width=7\TPHorizModule]{everybody}\par
\end{textblock}
\end{document}
答案3
以下是使用我自己电脑中的图像的示例。你可以使用自己的图像。
\documentclass[10pt]{book}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand\myhoffset{0.75in}
\newcommand\mytitlesep{1.00cm}
\newcommand\portraitscalefactor{85/100}
\newcommand\portraitheight{\dimexpr1in*\portraitscalefactor}
\newcommand\portraitwidth{\dimexpr1in*\portraitscalefactor}
\newcommand\portraitvoffset{\dimexpr\paperheight-1in*\portraitscalefactor*12\relax/2}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
%% creating the black background
\fill[black] (current page.north west) rectangle (current page.south east);
%% gray sidebar
\fill[gray] (current page.north west) rectangle ($(current page.south west)+(\myhoffset*2,0)$);
%% setting up the title
\node[white,scale=3.0] (title) at ($(current page.north)+(\myhoffset,-2in)$) {\textbf{PROBABILITY THEORY}};
\node[white,scale=2.0] (subtitle) at ($(title.south)+(0,-\mytitlesep)$) {\textbf{A Modern Comprehensive Course}};
%% double line below title
\begin{scope}[transform canvas={yshift=-\dimexpr\mytitlesep*2+1ex},
my y shift/.style={yshift=-5pt}]
\draw[line width=1.5pt,white] (title.south west) -- (title.south east);
\draw[line width=1.5pt,white] ([my y shift]title.south west) -- ([my y shift]title.south east);
\end{scope}
%% the main feature picture
\node at ($(current page.center)+(\myhoffset,-\dimexpr\mytitlesep*3+0.25in)$)
{\includegraphics[width=4in]{images/shantideva}};
%% the side portraits
\foreach \mypic [count=\myn from 0] in {%%
chick,
demon,
no_you_cant,
cameraman,
chick,
demon,
no_you_cant,
cameraman,
chick,
demon,
no_you_cant,
cameraman}
{
\node at ($(current page.north west)+(0.75in,-\dimexpr\portraitvoffset+\portraitheight/2+\portraitheight*\myn\relax)$)
{\includegraphics[width=\portraitwidth,height=\portraitheight]{images/\mypic.png}};
}
\end{tikzpicture}
\end{document}
答案4
- 对我来说,标题页本身就在第一页。
- 当第一个小页面宽度为
{0.18\textwidth}
,第二个小页面宽度为时,小页面是均匀的{0.85\textwidth}
。 - 在两个小页面环境之间写入命令
\hspace{-0.3cm}
并执行代码,您将得到所需的结果。