5

I'm a LaTeX newbie. I want to create a page layout like in the picture below on every page.

Can someone help please? Thanks.

example

lockstep
  • 250,273
kmmm
  • 63

2 Answers2

7

Since you want to have the layout for every page you could define a header containing a table instead of making the whole page a table, i.e. \chead{\begin{tabular} ... \end{tabular}} (with help of the standard package fancyhdr). In the final solution I used tabularx to build the actual table:

\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}

output

Ruben
  • 13,448
6

Update

According to comments, the first page has a different formatting. The code now uses a conditional to produce the desired results.

Here's one way to do it using the background and tikzpagenodes packages; the code needs two or three runs for the elements to reach their final locations:

enter image description here

The code:

\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}

Three auxiliary length allow easily customization:

  • \FrameHShift, horizontal separation between the text and the frame.
  • \FrameVShiftT, vertical separation between text and the lower part of the header.
  • \FrameVShiftB, vertical separation between text and lower part of the frame.
Gonzalo Medina
  • 505,128
  • Gonzalo, This is exactly what I want for my 1st page. The rest of them are a little bit different but I'll try to learn and adapt yours to fit my need. I might come back with more questions. Thanks. – kmmm Aug 29 '15 at 03:50
  • @kmmm -- How do you want the pages to look like from the second on? – Ruben Aug 30 '15 at 21:34
  • Ruben, Thanks for asking about the second page. It looks like the first page without a second row. I'll adjust yours and Gonzalo after I learn new commands. Both your and Gonzalo have many new commands that I never used before. So, I've to get familiar with it. I previously used just only the common packages for my thesis. – kmmm Sep 01 '15 at 03:05
  • @kmmm I updated my answer providing a different formatting from the second page on. – Gonzalo Medina Sep 02 '15 at 15:31
  • 1
    @kmmm Glad I could help. Yes, using conditional tests you can decide what to place on selected pages. – Gonzalo Medina Sep 04 '15 at 01:55
  • @Gonzalo, I really appreciate your helps. I noticed that you use if... conditions to show what you want on desired pages. So, I guess I can use \ifnum\value{page}=1 ..............do format 1.............. else...........do format 2............. else if last page...................do format 3.

    Another one, could you please more clear about these commands at (text4.north west) (text1) {text a}; Thanks.

    – kmmm Sep 04 '15 at 01:59
  • Gonzalo, I adjusted your format to fit my needs and separated that into another file, let says, ch1. Then I used command \input{ch1} on my main tex file, everything works like I want. Then I duplicated ch1 to ch2, kept everything identical and added \input{ch2} on my main tex file. The first page of ch2 (let says ch1 had 3 pages, so the first page of ch2 is 4), page 4 in this case, did not had the same pattern as page 1. I want the first page of every chapter has the same pattern. What command should I modify?. Thanks. – kmmm Sep 09 '15 at 08:40
  • @kmmm That's not ewhat you asked in your question, is it? You question clearly says that you want a design like the one in the image "on every page". If you want to change the design for the first pages of each chapter, that's a completely different matter and, in this case, I'm afraid the approach in my answer is not that flexible. Another approach using fancyhdr might be preferable. – Gonzalo Medina Sep 09 '15 at 17:48
  • @GonzaloMedina Would you mind helping me again please?. I like your style cause I can adjust the frame pattern to be what I want now. I would like to have the same pattern for every chapters so that I can separate them as ch1, ch2, ch3, and so on but the page number should be continue. Thanks in advance. – kmmm Sep 14 '15 at 16:09
  • @Gonzalo If you are free, please help me again. I really need it and really appreciate your help in advance. Thanks. – kmmm Sep 29 '15 at 09:07