2

I'd like to know if there's a newbie friendly way to create something like the table (it doesn't have to be a table if there's some other options that produce a similar template) in the pictures. In word it was pretty easy to do. Now I'd like to do the same in latex if possible.

I tried to create a table but couldn't enter equations into the cells. From searching online I found this question (How to put a formula into a table cell) and one answer says that we can't use $\begin{equation} .. \end{equation}$ inside table cells. The second answer says it is possible but not a good idea if the tabular is a floating

My question: is there a way to create this "template" once (in latex) and then treat the bigger cell like it's the whole page? Ignore what's outside of it's borders so I can use the same "template" for multiple pages.

I started with this code example. The 'summary' cell looks nice horizontally but it should be the only cell in it's row with other rows with columns over/under it.

\documentclass{article} 
\usepackage[english]{babel}

\begin{document}


With width specified:
\begin{center}
    \begin{tabular}{ | l | l | l | p{5cm} |}
        \hline
        Day & Min Temp & Max Temp & Summary \\ \hline
        Monday & 11C & 22C & A clear day with lots of sunshine.  
        However, the strong breeze will bring down the temperatures. \\ \hline
        Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells 
        across most of Scotland and Northern Ireland, 
        but rain reaching the far northwest. \\ \hline
        Wednesday & 10C & 21C & Rain will still linger for the morning. 
        Conditions will improve by early afternoon and continue 
        throughout the evening. \\
        \hline
    \end{tabular}
\end{center}

\end{document}

This looks pretty hacky to me. It'd be nice to know if there's a proper way of doing this.

Note that I'm new to linux and latex. Using Texstudio on openSUSE.

enter image description here

enter image description here

12
  • What is your paper size, with a left margin of 20 cm?
    – Bernard
    Nov 27, 2015 at 0:56
  • It's a standard A4. Portrait layout. Nov 27, 2015 at 0:58
  • 1
    You can't have a left margin of 20cm, a right margin of 5cm, and text in paper width of 21 cm!
    – Bernard
    Nov 27, 2015 at 0:59
  • @Bernard: A left margin of 20cm? ;-)
    – user31729
    Nov 27, 2015 at 1:01
  • 1
    XD. No. I can't. I should have put 20 mm there. Sorry. I'll edit the embarrasiing picture. Nov 27, 2015 at 1:01

1 Answer 1

5

Well, "simple" is relarive I guess. Here's a concept of what you can do with the help of the tikzpagenodes package and the calc library of TikZ. First you specify the margins, the text separation and the height of the boxes as you like. Then a picture is drawn in overlay mode to get the various black lines. The synatx for the coordinate computation is

  • ($(A)+(B)$): add the coordinates A and B
  • ($(A)!c!(B)$): the point at fraction 'c' between A and B

For the header I already defined somthing that looks a bit like your requirement, try playing with the numbers to tweak it. For the footer you'll have to define a few more coordinates.

Code

\documentclass{scrartcl}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}

% ===== set these values to your liking

\pgfmathsetlengthmacro{\LeftMargin}{20mm}
\pgfmathsetlengthmacro{\RightMargin}{5mm}
\pgfmathsetlengthmacro{\TopMargin}{25mm}
\pgfmathsetlengthmacro{\BottomMargin}{15mm}

\pgfmathsetlengthmacro{\Sep}{2mm} % distance between black border and text

\pgfmathsetlengthmacro{\TopBoxHeight}{15mm}
\pgfmathsetlengthmacro{\BottomBoxHeight}{20mm}

% ============================================

\pgfmathsetlengthmacro{\LEFT}{\LeftMargin + \Sep}
\pgfmathsetlengthmacro{\RIGHT}{\RightMargin + \Sep}
\pgfmathsetlengthmacro{\TOP}{\TopMargin + \Sep + \TopBoxHeight}
\pgfmathsetlengthmacro{\BOTTOM}{\BottomMargin + \Sep + \BottomBoxHeight}


\usepackage%
[   left=\LEFT,
    right=\RIGHT,
    top=\TOP,
    bottom=\BOTTOM
]{geometry}

\usepackage{lipsum}

\begin{document}

\pagestyle{empty}

\lipsum[1]

\begin{tikzpicture}[overlay, remember picture]
    \coordinate (A) at ($(current page text area.north west)+(-\Sep,+\Sep)$);
    \coordinate (B) at ($(current page text area.north east)+(+\Sep,+\Sep)$);
    \coordinate (C) at ($(current page text area.south west)+(-\Sep,-\Sep)$);
    \coordinate (D) at ($(current page text area.south east)+(+\Sep,-\Sep)$);

    \draw (C) rectangle (B); % box around text

    \path (A) ++ (0,\TopBoxHeight) coordinate (E);
    \path (B) ++ (0,\TopBoxHeight) coordinate (F);

    \draw (A) rectangle (F); % top box

    \path (C) ++ (0,-\BottomBoxHeight) coordinate (G);
    \path (D) ++ (0,-\BottomBoxHeight) coordinate (H);

    \draw (G) rectangle (D); % bottom box

    % ===== add whatever you like here

    \coordinate (I) at ($(A)!0.375!(B)$);
    \coordinate (J) at ($(A)!0.75!(B)$);

    \coordinate (K) at ($(I)+(0,\TopBoxHeight/2)$);
    \coordinate (L) at ($(J)+(0,\TopBoxHeight/2)$);
    \coordinate (M) at ($(B)+(0,\TopBoxHeight/2)$);

    \draw (I) -- ++ (0,\TopBoxHeight) coordinate (N);
    \draw (J) -- ++ (0,\TopBoxHeight) coordinate (O);
    \draw (K) -- (M);

    \node[text width=5cm, align=center] at ($(E)!0.5!(I)$) {\textsc{Xitragupten}\\ some more text};
    \node[text width=5cm, align=center] at ($(K)!0.5!(O)$) {debt register};
    \node[text width=5cm, align=center] at ($(I)!0.5!(L)$) {the beyond};
    \node[text width=5cm, align=center] at ($(M)!0.5!(O)$) {134217728};
    \node[text width=5cm, align=center] at ($(J)!0.5!(M)$) {131072};

    % ===== a helper to show the positions of the coordinates   

    \coordinate (center) at ($(A)!0.5!(D)$);
    \foreach \P in {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O}
    {   \node[fill= yellow!30, draw, inner sep=1pt,circle] (dummy) at ($(\P)!0.3!(center)$) {\P};
        \draw[-latex] (dummy) -- (\P);
    }

    \foreach \x [count=\c] in {hoffset, voffset, oddsidemargin, topmargin, headheight, headsep, textheight, textwidth, marginparsep, marginparwidth, footskip, paperwidth, paperheight}
    {   \node[right] at (0,-0.7*\c) {\x\ = \pgfmathparse{\csname\x\endcsname}\pgfmathresult pt = \pgfmathparse{\csname\x\endcsname/28.452756}\pgfmathresult cm};
    }
\end{tikzpicture}

\end{document}

Output

enter image description here

1
  • 1
    Well, with simple I meant something that could be done by a latex newbie definitely with less code than what you've written. But you've done almost all the work for me. So, now I believe I can tweak your code a little bit and get exactly what I was aiming for. This is a great answer and helps me a lot. I hope it will, also, be useful for others.Thank You very much. :) Dec 5, 2015 at 18:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .