如何创建这样的页面?

如何创建这样的页面?

我是 LaTeX 新手。我想在每一页上创建如下图所示的页面布局。

有人能帮忙吗?谢谢。

例子

答案1

更新

根据评论,第一页的格式有所不同。代码现在使用条件来产生所需的结果。

这里有一种方法可以使用backgroundtikzpagenodes包;代码需要运行两到三次才能使元素到达最终位置:

在此处输入图片描述

代码:

\documentclass{article}
\usepackage[scale=1,angle=0,opacity=1,color=black]{background}
\usepackage{tikzpagenodes}
\usepackage{lipsum}

\newlength\FrameHShift
\newlength\FrameVShiftT
\newlength\FrameVShiftB
\setlength\FrameHShift{20pt}
\setlength\FrameVShiftT{15pt}
\setlength\FrameVShiftB{75pt}

\backgroundsetup{
  contents={%
  \begin{tikzpicture}[overlay]
  \coordinate (nw) at ([shift={(-\FrameHShift,\FrameVShiftT)}]current page text area.north west);
  \coordinate (ne) at ([shift={(\FrameHShift,\FrameVShiftT)}]current page text area.north east);
  \coordinate (sw) at ([shift={(-\FrameHShift,-\FrameVShiftB)}]current page text area.south west);
  \coordinate (se) at ([shift={(\FrameHShift,-\FrameVShiftB)}]current page text area.south east);
  \draw
    (nw) --
    (ne) --
    (se) --
    (sw)-- cycle;
  \ifnum\value{page}=1
  \node[
    draw,
    anchor=south west,
    text width=0.25\textwidth,
    minimum height=10ex,
    align=center,
    yshift=-\pgflinewidth
    ]
    at (nw)
    (text4)
    {text d \\ text d};
  \node[
    draw,
    anchor=south west,
    text width=0.25\textwidth,
    minimum height=5ex,
    align=center,
    yshift=-\pgflinewidth
    ]
    at (text4.north west)
    (text1)
    {text a};
  \node[
    draw,
    anchor=south west,
    text width=0.5\textwidth,
    minimum height=5ex,
    align=center,
    xshift=-\pgflinewidth
    ]
    at (text1.south east)
    (text2)
    {text b};
  \node[
    draw,
    anchor=south west,
    text width=\dimexpr0.25\textwidth+2\FrameHShift-\pgflinewidth\relax,
    minimum height=5ex,
    align=center,
    xshift=-\pgflinewidth
    ]
    at (text2.south east)
    (text3)
    {text c};
  \node[
    draw,
    anchor=south west,
    text width=\dimexpr0.75\textwidth+2\FrameHShift-\pgflinewidth\relax,
    minimum height=10ex,
    align=center,
    xshift=-\pgflinewidth
    ]
    at (text4.south east)
    (text5)
    {text e \\ text e};
  \node[anchor=north]
    at ([yshift=-50pt]current page text area.south)
    {Page~\thepage};
  \else
  \node[
    draw,
    anchor=south west,
    text width=0.25\textwidth,
    minimum height=5ex,
    align=center,
    xshift=-0.5\pgflinewidth,
    yshift=-\pgflinewidth
    ]
    at (nw)
    (text1)
    {text a};
  \node[
    draw,
    anchor=south west,
    text width=0.5\textwidth,
    minimum height=5ex,
    align=center,
    xshift=-\pgflinewidth
    ]
    at (text1.south east)
    (text2)
    {text b};
  \node[
    draw,
    anchor=south west,
    text width=\dimexpr0.25\textwidth+2\FrameHShift\relax,
    minimum height=5ex,
    align=center,
    xshift=-\pgflinewidth
    ]
    at (text2.south east)
    (text3)
    {text c};
  \fi    
   \end{tikzpicture}%
  }
}

\pagestyle{empty}

\begin{document}

\lipsum[1-30]

\end{document}

三种辅助长度可轻松定制:

  • \FrameHShift,文本与框架之间的水平分隔。
  • \FrameVShiftT,文本和页眉下部之间的垂直分隔。
  • \FrameVShiftB,文本与框架下部之间的垂直分隔。

答案2

由于您希望每个页面都有布局,因此您可以定义一个包含表格的标题,而不是将整个页面都变成表格\chead{\begin{tabular} ... \end{tabular}}(借助标准包fancyhdr)。在最终解决方案中,我用来tabularx构建实际表格:

\documentclass{article}
\usepackage[top=125pt,headheight=75pt,headsep=10pt]{geometry}
\usepackage{fancyhdr}
  \pagestyle{fancy}
  \fancyhf{}
  \chead{%
    \renewcommand{\arraystretch}{1.75}%
    \begin{tabularx}{\textwidth}{|c|>{\centering\arraybackslash}X|c|}
      \hline
      Text here & Text here & Text here \\[5pt]
      \hline
      Text here & \multicolumn{2}{c|}{%
        \vtop{%
          \hbox{\strut Text here}
          \hbox{\strut Text here}
        }
      } \\[15pt]
      \hline
    \end{tabularx}%
  }
  \cfoot{\thepage}
  \renewcommand{\headrulewidth}{0pt}
\usepackage{tabularx}
\makeatletter
\newdimen\@ht
\@ht\dimexpr\textheight+\headheight+\headsep+2em\relax
\AtBeginDocument{%
  \leftskip1em
  \rightskip1em
  \AtBeginDvi{%
    \moveright\@themargin%
    \vbox to\z@{\baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@%
      \hbox to\textwidth{%
        \llap{\vrule height\@ht}\hfil%
        \vrule height\@ht
      }%
      \vbox to\z@{\vss\hrule width\textwidth}%
      \vss
    }
  }
}
\makeatother

\begin{document}
\vspace*{0.3\textwidth}
{\LARGE\centering Text here\par}
\end{document}

输出

相关内容