我试图将图片放在标题页的底部,但出现了一个非常小的垂直间隙,我想将其删除。以下是 MWE,用于显示我的问题:
\documentclass[letterpaper]{book}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{libertine}
\renewcommand*\familydefault{\sfdefault}
\usepackage{anysize}
\marginsize{1.5in}{1in}{0.5in}{0.5in}
\usepackage[x11names]{xcolor}
\definecolor{backgroundcolor}{RGB}{150, 170, 190}
\usepackage{graphicx}
\usepackage{here}
\usepackage{afterpage}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand*{\maintitle}{\begingroup
\pagecolor{backgroundcolor}
\vfill
\raggedleft {\huge Name}
\begin{figure}[H]
\center
\includegraphics[width=1\textwidth]{example-image}
\end{figure}
\endgroup}
\begin{document}
\begin{titlepage}
% CADRE :
\begin{tikzpicture}[remember picture, overlay]
\draw[line width = 1in,color = white] ($(current page.north west) + (0.25in,0.25in)$) rectangle ($(current page.south east) + (0.25in,-0.25in)$);
\draw[line width = 0.25pt,color = black] ($(current page.north west) + (0.75in,-0.25in)$) rectangle ($(current page.south east) + (-0.25in,0.25in)$);
\draw[line width = 1pt,color = white] ($(current page.north west) + (1in,-0.5in)$) rectangle ($(current page.south east) + (-0.5in,0.5in)$);
\end{tikzpicture}
\maintitle
\end{titlepage}
\end{document}
预览,问题以红色显示:
乍一看,间距五等于H, 哪个就是我想要的。但仔细观察就会发现五实际上略大于H. 我该如何五完全一样H? 我的代码有什么问题?
编辑: 缩放和测量后,差异为垂直 - 高度 = 1pt。这与底部绘制的白线粗细相同,但我怀疑这只是巧合。我可以通过\vspace{-1pt}
在我的图形环境下添加来解决我的问题,但我想了解(并正确修复)该问题。
答案1
在页面背景上绘图可能更容易一些eso-pic
。这也只需要编译一次。尺寸与您的不同,但我相信您可以弄清楚。
\documentclass[letterpaper]{book}
\usepackage{eso-pic}
\usepackage{tikz}
\usepackage{xcolor}
\definecolor{backgroundcolor}{RGB}{150,170,190}
\begin{document}
\AddToShipoutPictureBG*{%
\AtTextLowerLeft{%
\begin{tikzpicture}[overlay]
\coordinate (ll) at (0,0);
\coordinate (ur) at (\textwidth,\textheight);
\draw[black,fill=backgroundcolor] ([shift={(-1in,-1in)}]ll) rectangle ([shift={(1in,1in)}]ur);
\draw[white] ([shift={(-.25in,-.25in)}]ll) rectangle ([shift={(.25in,.25in)}]ur);
\useasboundingbox (ll) rectangle (ur);
\end{tikzpicture}%
}%
}
\begin{titlepage}
\raggedleft
\leavevmode
\vfill
\huge Name\par
\includegraphics[width=1\textwidth]{example-image}
\end{titlepage}
\end{document}
答案2
我认为图片/图像可以直接作为节点放置在 tikz 中,而不是单独的begingroup
如果我知道页角的精确位置(红色圆圈)
\node[inner sep=0pt, circle,red,fill,draw, minimum size=6pt] at
(%
$(current page text area.south west)+
(-0.75in,-0.6in)$
){};
然后我可以精确计算任何其他位置——在你的情况下V
,h
通过从 x 和 y 侧增加相同的量
\node[inner sep=0pt, circle,red,fill,draw, minimum size=6pt] at (%
$(current page text area.south west)+
% (-0.75in,-0.6in)+<------------------increment v=.2in h=.2in from each side
(-0.55in,-0.4in)$){};
\documentclass[letterpaper]{book}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{libertine}
\renewcommand*\familydefault{\sfdefault}
\usepackage{anysize}
\marginsize{1.5in}{1in}{0.5in}{0.5in}
\usepackage[x11names]{xcolor}
\definecolor{backgroundcolor}{RGB}{150, 170, 190}
\usepackage{graphicx}
\usepackage{here}
\usepackage{afterpage}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}
\newcommand*{\maintitle}{\begingroup%
\pagecolor{backgroundcolor}
\vfill
\raggedleft {\huge Name}
\begin{figure}[H]
\center
\includegraphics[width=1\textwidth]{example-image}
\end{figure}
\endgroup}%
\begin{document}
\begin{titlepage}
% CADRE :
\begin{tikzpicture}[remember picture, overlay]
\draw[line width = 1in,color = white] ($(current page.north west) +
(0.25in,0.25in)$) rectangle ($(current page.south east) + (0.25in,-0.25in)$);
\draw[line width = 0.25pt,color = black] ($(current page.north west) +
(0.75in,-0.25in)$) rectangle ($(current page.south east) + (-0.25in,0.25in)$);
\draw[line width = 1pt,color = white] ($(current page.north west) +
(1in,-0.5in)$) rectangle ($(current page.south east) + (-0.5in,0.5in)$);
\end{tikzpicture}
\maintitle
\begin{tikzpicture}[remember picture,overlay]
\node[inner sep=0pt, circle,red,fill,draw, minimum size=6pt] at
(%
$(current page text area.south west)+
(-0.75in,-0.6in)$
){};
\node[inner sep=0pt, circle,red,fill,draw, minimum size=6pt] at (%
$(current page text area.south west)+
% (-0.75in,-0.6in)+
(-0.55in,-0.4in)$){};
%\node at (0,0) {\includegraphics[width=4cm]{example-image}};
\end{tikzpicture}
\end{titlepage}
\end{document}
编辑
我忘了添加图片
\node[inner sep=0pt] at (%
$(current page text area.south west)+
% (-0.75in,-0.6in)+
(-0.55in,-0.4in)$){\includegraphics[scale=0.2]{example-image}};
平均能量损失
\documentclass[letterpaper]{book}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{libertine}
\renewcommand*\familydefault{\sfdefault}
\usepackage{anysize}
\marginsize{1.5in}{1in}{0.5in}{0.5in}
\usepackage[x11names]{xcolor}
\definecolor{backgroundcolor}{RGB}{150, 170, 190}
\usepackage{graphicx}
\usepackage{here}
\usepackage{afterpage}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}
\newcommand*{\maintitle}{\begingroup%
\pagecolor{backgroundcolor}
\vfill
\raggedleft {\huge Name}
\begin{figure}[H]
\center
\includegraphics[width=1\textwidth]{example-image}
\end{figure}
\endgroup}%
\begin{document}
\begin{titlepage}
% CADRE :
\begin{tikzpicture}[remember picture, overlay]
\draw[line width = 1in,color = blue] ($(current page.north west) + (0.25in,0.25in)$) rectangle ($(current page.south east) + (0.25in,-0.25in)$);
\draw[line width = 0.25pt,color = black] ($(current page.north west) + (0.75in,-0.25in)$) rectangle ($(current page.south east) + (-0.25in,0.25in)$);
\draw[line width = 1pt,color = green] ($(current page.north west) + (1in,-0.5in)$) rectangle ($(current page.south east) + (-0.5in,0.5in)$);
\end{tikzpicture}
% \maintitle
\begin{tikzpicture}[remember picture,overlay]
\node[inner sep=0pt, circle,red,fill,draw, minimum size=6pt] at
(%
$(current page text area.south west)+
(-0.75in,-0.6in)$
){};
\node[inner sep=0pt, circle,red,fill,draw, minimum size=6pt] at (%
$(current page text area.south west)+
% (-0.75in,-0.6in)+
(-0.55in,-0.4in)$){};
\node[inner sep=0pt] at (%
$(current page text area.south west)+
% (-0.75in,-0.6in)+
(-0.55in,-0.4in)$){\includegraphics[scale=0.2]{example-image}};
%\node at (0,0) {\includegraphics[width=4cm]{example-image}};
\end{tikzpicture}
\end{titlepage}
\end{document}
如果你现在看到,使用 tikz 和删除 maketitle 可以获得更好的精度,正如@HenriMenke 类似评论的那样
编辑2
\documentclass[letterpaper]{book}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{libertine}
\renewcommand*\familydefault{\sfdefault}
\usepackage{anysize}
\marginsize{1.5in}{1in}{0.5in}{0.5in}
\usepackage[x11names]{xcolor}
\definecolor{backgroundcolor}{RGB}{150, 170, 190}
\usepackage{graphicx}
\usepackage{here}
\usepackage{afterpage}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}
\usepackage{tikzpagenodes}
%\newcommand*{\maintitle}{\begingroup%
% \pagecolor{backgroundcolor}
% \vfill
% \raggedleft {\huge Name}
% \begin{figure}[H]
% \center
% \includegraphics[width=1\textwidth]{example-image}
% \end{figure}
% \endgroup}%
\begin{document}
\pagecolor{backgroundcolor}
\begin{titlepage}
\begin{tikzpicture}[remember picture, overlay]
\draw[line width = 1in,color = blue!30] ($(current page.north west) + (0.25in,0.25in)$) rectangle ($(current page.south east) + (0.25in,-0.25in)$);
\draw[line width = 0.25pt,color = black] ($(current page.north west) + (0.75in,-0.25in)$) rectangle ($(current page.south east) + (-0.25in,0.25in)$);
\draw[line width = 1pt,color = green] ($(current page.north west) + (1in,-0.5in)$) rectangle ($(current page.south east) + (-0.5in,0.5in)$);
\end{tikzpicture}
\begin{tikzpicture}[remember picture,overlay, every label/.style=left,]
\node[name=temp1, inner sep=0pt, circle,red,fill,draw, minimum size=6pt,anchor=center, label=a] at
(%
$(current page text area.south west)+
(-0.75in,-0.6in)$
){} ;
\node[name=temp2,inner sep=0pt, circle,red,fill,draw, minimum size=6pt,anchor=center, label=b] at (%
$(current page text area.south west)+
% (-0.75in,-0.6in)+
(-0.05in,0.1in)$){};
\node[name=temp3,inner sep=0pt, circle,red,fill,draw, minimum size=6pt, label=c] at (%
$(current page text area.south west)+
% (-0.75in,-0.6in)+
(-0.05in,-0.6in)$){};
\node[name=temp4,inner sep=0pt, circle,red,fill,draw, minimum size=6pt, label=d] at (%
$(current page text area.south west)+
% (-0.75in,-0.6in)+
(-0.75in,0.1in)$){};
\node[name=temp5,inner sep=0pt, anchor=south west] at (%
$(current page text area.south west)+
% (-0.75in,-0.6in)+
(-0.05in,0.1in)$)(b){\includegraphics[scale=1,width=\linewidth]{example-image}} node[above=of b.north, yshift=-1cm, xshift=7cm ](){\Large Name};
\draw(temp2)--node[midway, fill=white]{0.7in}(temp4);
\draw(temp2)--node[midway, fill=white]{0.7in}(temp3);
\end{tikzpicture}
\end{titlepage}
\end{document}