【问题标题】:LaTeX document with several margin settings具有多个边距设置的 LaTeX 文档
【发布时间】:2021-11-23 13:14:18
【问题描述】:

我正在处理需要两种不同边距设置的乳胶文档。

第一部分是一个标题,两边必须有 0.25 英寸。它由一张图片和两列排列的三到五行文本组成。

第二部分是正文,两边各1in。此文本可能长达数页。

页眉只显示在第一页。

在该标题之后,第二部分开始,在同一页面中。第二部分是文档的主体。

我使用几何页面设置页边距(用于页眉),但如果写页眉然后使用 \newgeometry 命令,正文从下一页开始,我需要将它们放在同一个页上。

我不想为标题使用图像,因为它会经常更改,我将创建许多具有该结构的文档。

是否有某种方法可以创建具有主要文本边距的文档并创建“异常边距”只是为了在同一页面上插入页眉?欢迎提出建议:-D

我尝试了以下方法:

\documentclass{article}

% This settings work for the header
\usepackage[margin=0.25in]{geometry}

% Dummy text generator
\usepackage{blindtext}

% Just to simulate logo
\usepackage{tikz}

\begin{document}
    
    % Document Header, first page only
    \begin{minipage}[t]{2in}
        \vskip0pt
        \begin{tikzpicture}
            \fill [blue!30] (0,0) rectangle (1.75in, 1.5in);
        \end{tikzpicture}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{2.5in}
        \vskip0pt
        This is the first text block with some info about the company, department another stuff. It is only text.
    \end{minipage}
    \hfill
    \begin{minipage}[t]{3in}
        \vskip0pt
        This is a second text block with information about content creator, editor, etc. and it just text.
    \end{minipage}

    \hrulefill

    % Starting from here, I need narrow margins, about 1 inch on the left and right. The text must start right after the header
    % I have tried with \newgeometry{left=1in,right=1in} but the text starts on the new page.

    \section{First section}

    \blindtext

    \section{Second section}

    \blindtext

    Text, text and more text... several pages of text...

\end{document}

【问题讨论】:

标签: layout latex


【解决方案1】:

快速破解:

\documentclass{article}

% This settings work for the header
\usepackage[margin=1in]{geometry}

% Dummy text generator
\usepackage{blindtext}

% Just to simulate logo
\usepackage{tikz}

\begin{document}

  \centerline{%
   \begin{minipage}{\dimexpr\paperwidth-0.5in\relax}
    % Document Header, first page only
    \begin{minipage}[t]{2in}
        \vskip0pt
        \includegraphics[width=\linewidth]{example-image-duck}
    \end{minipage}%
    \hfill%
    \begin{minipage}[t]{2.5in}
        \vskip0pt
        This is the first text block with some info about the company, department another stuff. It is only text.
    \end{minipage}%
    \hfill%
    \begin{minipage}[t]{3in}
        \vskip0pt
        This is a second text block with information about content creator, editor, etc. and it just text.
    \end{minipage}%
    
    \hrulefill
   \end{minipage}
 }
 

    % Starting from here, I need narrow margins, about 1 inch on the left and right. The text must start right after the header
    % I have tried with \newgeometry{left=1in,right=1in} but the text starts on the new page.

    \section{First section}

    \blindtext

    \section{Second section}

    \blindtext

    Text, text and more text... several pages of text...

\end{document}

【讨论】:

  • 就是这样!非常感谢,也感谢鸭子。昨天我访问了您的 stackoverflow 个人资料,发现了鸭子!再次感谢。
  • @RaúlUriarte 不客气!很高兴听到你喜欢鸭子:)
猜你喜欢
  • 2011-02-03
  • 1970-01-01
  • 2021-12-09
  • 2014-08-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多