页面中的图形覆盖了页面高度和左边距

页面中的图形覆盖了页面高度和左边距

我想将图形放在页面左侧,不留任何边距。我一直在测试以下内容:

\documentclass[a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage[absolute]{textpos}
\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{1mm}
\textblockorigin{0mm}{0mm} % start everything near the top-left corner
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\begin{document}
\thispagestyle{empty}
\newgeometry{left=0in,right=0in,top=0in,bottom=0in,bindingoffset=0in}
   %--\begin{textblock}{⟨hsize ⟩}(⟨hpos ⟩,⟨vpos ⟩)
   \begin{textblock}{3.5}(-1,1)
      \includegraphics{teleco/ETS35.pdf}
    \end{textblock}

\textblockorigin{30mm}{30mm}
\begin{textblock}{158}(10,15)   
\begin{center}
\HRule \\[0.6cm]
{ \huge \bfseries Network Management:}\\[0.4cm]
{\huge \bfseries A practical Approach} \\[0.4cm]
\HRule \\[2.0cm]

\begin{figure}[htbp]
    \centering
        \includegraphics[height=2.5in]{teleco/internet.png}
    %\caption{caption}
    \label{fig:Desktop_2014-12-02-networks-640x512}
\end{figure}
\vspace{2.75cm}
{\Large \bfseries John Smith}\\[0.4cm]
{\Large \bfseries Departamento de Tecnologías de la Información y las Comunicaciones}\\[1.5cm]
{\LARGE \bfseries E.T.S.I.T}\\[0.5cm]
{\LARGE \bfseries TECHNICAL UNIVERSITY OF \\[0.15cm] CARTAGENA}\\[0.75cm]
\vfill {
}
\end{center}
\end{textblock}
\end{document}

编译出来的页面类似如下:

页面无边距

左侧图片的左侧、上方和底部都有空白。我想将左侧(长)图片填充到这些空白处。

我该怎么做才能做到?谢谢。

答案1

您发现的问题是由第一个textblock设置{3.5}(-1,1)和默认\parindent设置的组合引起的6pt(-1,1)将图像放置的原点从 向左移动 1mm,向下移动 1mm,\textblockorigin位于 的左上角(0,0)。这与 x 方向的 6bp 增加相结合,因为\parindent会偏移您的图像。

我建议没有必要使用\newgeometry或重新安置\textblockorigin。消除此代码可使布局逻辑在整个代码中保持一致。

所以:

  1. 添加\setlength\parindent{0pt}
  2. 删除%\newgeometry{left=0in,right=0in,top=0in,bottom=0in,bindingoffset=0in}
  3. 删除%\textblockorigin{30mm}{30mm}
  4. 更改\begin{textblock}{3.5}(-1,1)\begin{textblock}{1}(0,0)放置example-image-A在左上角
  5. 更改\begin{textblock}{158}(10,15)\begin{textblock}{158}(40,45),定位文本和example-image-B,而不重新定位\textblockorigin

编辑 OP 随后指出左侧图像未延伸至整个页面高度。为了确保图像延伸至整个纸张高度,我们必须使用height=1.0\paperheight作为选项\includegraphics。为了显示页面边框并证明图像延伸至整个页面高度,我使用 添加了 OP 的图像和边框TikZ。这位于背景层上,因此使用testpos框放置的图像和文本会覆盖边框。这需要添加overlay到包的类选项中textpos

结果如下:

在此处输入图片描述

这是 MWE:

\documentclass[a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage[absolute,overlay]{textpos}
\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{1mm}
\textblockorigin{0mm}{0mm} % start everything near the top-left corner
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\setlength\parindent{0pt}

\usetikzlibrary{backgrounds}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay]
\begin{pgfonlayer}{background}
\draw[line width=3mm,red!50] (current page.north west) rectangle (current page.south east);
\end{pgfonlayer}
\end{tikzpicture}

%\newgeometry{left=0in,right=0in,top=0in,bottom=0in,bindingoffset=0in,showframe}
   %--\begin{textblock}{⟨hsize ⟩}(⟨hpos ⟩,⟨vpos ⟩)
   \begin{textblock}{1}(0,0) % was {3.5}(-1,1)
      \includegraphics[width=3cm,height=1.0\paperheight]{ETS35}
    \end{textblock}

%\textblockorigin{30mm}{30mm}
\begin{textblock}{158}(40,45)   % was {158}(10,15)
\begin{center}
\HRule \\[0.6cm]
{ \huge \bfseries Network Management:}\\[0.4cm]
{\huge \bfseries A practical Approach} \\[0.4cm]
\HRule \\[2.0cm]

\begin{figure}[htbp]
    \centering
        \includegraphics[height=2.5in]{internet}
    %\caption{caption}
    \label{fig:Desktop_2014-12-02-networks-640x512}
\end{figure}
\vspace{2.75cm}
{\Large \bfseries John Smith}\\[0.4cm]
{\Large \bfseries Departamento de Tecnologías de la Información y las Comunicaciones}\\[1.5cm]
{\LARGE \bfseries E.T.S.I.T}\\[0.5cm]
{\LARGE \bfseries TECHNICAL UNIVERSITY OF \\[0.15cm] CARTAGENA}\\[0.75cm]
\vfill {
}
\end{center}
\end{textblock}
\end{document}

相关内容