Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to create a complex template for documentation as a document class.

I should be able to define my text fields (for instance, \documentNumber, \projectTitle). My class should be flexible enough to accomodate landscape pages as well. XeTeX is preferrable.

This is a sketch of how the document template should look like:

Layout sketch

The only idea I had was to create a tikzpicture on every page, as described in my other question. I got recommendations for using everypage, everyshi and such. I was hoping for more specific answers. Code snippets or just outlined concepts for coding are most welcome.

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

Following Matthew's prediction, this is how I would do this layout in ConTeXt. The table at the top can be set as a header. The callouts on the left margin can be set using layers. We can add frames (borders) by carefully adding frame=on or frame=off to different elements. The rest is just a matter of setting the right margin's etc.

\setuplayout  
  [topspace=1\lineheight,
   top=1\lineheight,
   topdistance=0cm,
   header=1.25in,
   headerdistance=0cm,
   height=fit,
   footerdistance=0cm,
   footer=0.5in,
   bottomspace=0.25\lineheight,
   bottom=0.25\lineheight,
   bottomdistance=0cm,
   backspace=0.75in,
   width=fit,
   cutspace=0.125in,
 ]

\setupbackgrounds[text][text][frame=on]

% Header
\setuppagenumbering[location=]
\setupheadertexts[\setups{header}]

% Left margin
\definelayer [leftlayer] 
             [width=\paperwidth,
              height=\paperheight,
              x=0cm,
              y=1cm]

\defineframed[margincallout]
             [height=\dimexpr\layoutparameter{backspace}\relax,                        
              width=\dimexpr(\textheight+\layoutparameter{header})/2\relax,
              align={middle,middle},
              foregroundstyle=\tfc,
              frame=off]

\setlayer        [leftlayer] [preset=leftbottom] 
                 {\rotate{\margincallout[rightframe=on]{Rotated text callout 1} }}

\setlayer        [leftlayer] [preset=lefttop,y=2.5mm]
                 {\rotate{\margincallout {Rotated text callout 2} }}

\setupbackgrounds[page][background=leftlayer]

% Actual content
\startsetups header
  \setupTABLE[each][each][height=\dimexpr\layoutparameter{header}/4\relax,
                          width=0.25\textwidth,
                          align={middle,middle},
                          frame=on]
  \bTABLE
    \bTR
      \bTD[nr=3]      \fakewords {5} {10} \eTD
      \bTD[nr=3,nc=2] \fakewords {5} {10} \eTD
      \bTD \fakewords{1}{3}               \eTD
    \eTR
    \bTR
       \bTD \fakewords{1}{3} \eTD
    \eTR
    \bTR
      \bTD \fakewords{1}{3} \eTD
    \eTR
    \bTR
      \bTD \fakewords{1}{2} \eTD
      \bTD \fakewords{1}{2} \eTD
      \bTD \fakewords{1}{2} \eTD
      \bTD \fakewords{1}{2} \eTD
    \eTR
  \eTABLE
\stopsetups


% For dummy text
\usemodule[visual]
\starttext
Page Content
\stoptext

The output looks as follows:enter image description here

share|improve this answer
    
I will accept your answer. It seems elegant and usable. As I don't have experience with ConTeXt, I'll also try and sketch my progress in LaTeX as a separate answer. –  ipavlic Feb 25 '11 at 11:59
    
one of these days I will go beyond predicting a context solution and actually try to write one. :) –  Matthew Leingang Mar 1 '11 at 12:55
add comment

You might try the textpos package or some of the other solutions described on the UK TeX FAQ page "Putting things at fixed positions on the page".

If you are comfortable using TikZ to do this kind of thing don't be afraid to. Yes, it's a lot of "overhead" but it works.

Although I know very little about it I hear ConTeXt does this kind of thing well. So we should be getting an answer from one of their users soon.

share|improve this answer
add comment

I have managed to solve my requirement with your generous help. I'm not very satisfied with the overall hackishness, but it solves my requirements. Hopefully it might be helpful to someone else.

Document:

\documentclass[12pt,a4paper]{class}

\usepackage{lipsum}

\projecttitle{My project name}
\metadata{Metadata}
\metadataTwo{Metadata Two}
\metadataThree{Metadata Three}
\metadataFour{Metadata Four}
\metadataFive{Metadata Five}
\metadataSix{Metadata Six}

\begin{document}

\section{Lipsum}
\lipsum[1]
\section{Phasellus eu tellus}
\lipsum[1-12]
\end{document}

Document class:

\ProvidesClass{class}
\LoadClass[12pt,a4paper]{article}

\newcommand{\projecttitle}[1]{\gdef\@projecttitle{#1}}
\newcommand{\metadata}[1]{\gdef\@metadata{#1}}
\newcommand{\metadataTwo}[1]{\gdef\@metadataTwo{#1}}
\newcommand{\metadataThree}[1]{\gdef\@metadataThree{#1}}
\newcommand{\metadataFour}[1]{\gdef\@metadataFour{#1}}
\newcommand{\metadataFive}[1]{\gdef\@metadataFive{#1}}
\newcommand{\metadataSix}[1]{\gdef\@metadataSix{#1}}

\usepackage{polyglossia}
\setmainlanguage{croatian}

\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont{Minion Pro}

\usepackage{geometry}
\geometry{%
    a4paper,%
    hmargin={3.5cm,2.5cm},%
    headheight=2cm,%
    headsep=1cm,%
    marginparwidth=1.1cm,%
    marginparsep=0.2cm%
}

\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{microtype}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzstyle{content box}=[]

\usepackage{lastpage}

\def\logowidthratio{0.25}
\def\titlewidthratio{0.5}
\def\rightcolumnwidthratio{0.25}

\newlength\framewidth
\setlength{\framewidth}{\paperwidth-3cm}
\newlength\frameheight
\setlength{\frameheight}{\paperheight-2cm}

\newlength{\logowidth}
\setlength{\logowidth}{\logowidthratio\framewidth}

\newlength{\titlewidth}
\setlength{\titlewidth}{\titlewidthratio\framewidth}

\newlength{\logoandtitlewidth}
\setlength{\logoandtitlewidth}{\logowidth+\titlewidth}

\newlength{\rightcolumnswidth}
\setlength{\rightcolumnswidth}{\framewidth - \logoandtitlewidth}

\newlength{\padding}
\setlength{\padding}{6pt}

\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.0pt}


\AtBeginDocument{
    \newsavebox{\logobox}
    \sbox{\logobox}{
        \parbox{\logowidthratio\framewidth-2\padding}{
            \centering
            \rule{\logowidth-2\padding}{2cm}% graphic dummy
            }
        }

    \newsavebox{\titlebox}
    \sbox{\titlebox}{\parbox{\titlewidthratio\framewidth-2\padding}{
        \centering\large\textsc{Project name}\linebreak\textbf{\@projecttitle}}
        }

    \newsavebox{\metadatabox}
    \sbox{\metadatabox}{
        \parbox{\rightcolumnswidth-2\padding}{Metadata: \@metadata}
        }

    \newsavebox{\docnumbox}
    \sbox{\docnumbox}{
        \parbox{\rightcolumnswidth-2\padding}{Metadata: \@metadataTwo}
        }

    \newsavebox{\revisionbox}
    \sbox{\revisionbox}{
        \parbox{\rightcolumnswidth-2\padding}{Metadata: \@metadataThree}
        }

    \newsavebox{\contractnumbox}
    \sbox{\contractnumbox}{
        \parbox{\logowidth-2\padding}{Metadata: \@metadataFour}
        }

    \newsavebox{\projectnumbox}
    \sbox{\projectnumbox}{
        \parbox{0.5\titlewidth-2\padding}{Metadata: \@metadataFive}
        }

    \newsavebox{\bookbox}
    \sbox{\bookbox}{
        \parbox{0.5\titlewidth-2\padding}{Metadata: \@metadataSix}
        }

    \newsavebox{\pagenumbox}
    \sbox{\pagenumbox}{
        \parbox{\rightcolumnswidth-2\padding}{\hphantom{Page: 123 of 123}}
        }

    \newlength\logoheight
    \settototalheight\logoheight{\usebox{\logobox}}
    \addtolength{\logoheight}{2\padding}

    \newlength\titleheight
    \settototalheight\titleheight{\usebox{\titlebox}}
    \addtolength{\titleheight}{2\padding}

    \newlength\metadataheight
    \settototalheight\metadataheight{\usebox{\metadatabox}}

    \newlength\docnumheight
    \settototalheight\docnumheight{\usebox{\docnumbox}}

    \newlength\revisionheight
    \settototalheight\revisionheight{\usebox{\revisionbox}}

    \newlength\contractnumheight
    \settototalheight\contractnumheight{\usebox{\contractnumbox}}

    \newlength\projectnumheight
    \settototalheight\projectnumheight{\usebox{\projectnumbox}}

    \newlength\bookheight
    \settototalheight\bookheight{\usebox{\bookbox}}

    \newlength\pagenumheight
    \settototalheight\pagenumheight{\usebox{\pagenumbox}}

    \newlength\rightcolumnheight
    \pgfmathsetlength{\rightcolumnheight}{3*(max(\metadataheight,\docnumheight,\revisionheight)+2\padding}

    %45 points is sligtly more than 1,5 cm
    \newlength\headerfirstrowheight
    \pgfmathsetlength{\headerfirstrowheight}{max(\logoheight,\titleheight,\rightcolumnheight,45)}

    \newlength\headerheight
    \pgfmathsetlength{\headerheight}{\headerfirstrowheight + max(\contractnumheight,\projectnumheight,\bookheight,\pagenumheight)+12pt}

    \newgeometry{vmargin={\headerheight+1.5cm,1.5cm}}

    \chead{%
        \begin{tikzpicture}[remember picture, overlay, semithick, black, inner sep=0, outer sep=0]%
        %
        % OUTER FRAME AND COPYRIGHT DIVIDER
        % 
        %
        %Outer frame
        \node (frame) at ($(current page.center)+(0.5cm,0)$) [minimum width=\paperwidth-3cm,minimum height=\paperheight-2cm, draw] {};%
        %
        %Copyright divider
        \draw ($(current page.west)+(0.2cm,0)$) -- ($(current page.west)+(1.8cm,0)$);%
        %
        %
        % CONTENT BOXES
        %
        %
        %Revision information
        \node (revision information) at ($(frame.north west)!0.98!(frame.south west)$) [content box, xshift=-0.4cm, anchor=west, rotate=90] {\tiny Revision information text};%
        %
        %Copyright notice Croatian
        \node (copyright hrvatski) at ($(frame.north west)!0.75!(frame.south west)$) [content box, xshift=-1cm, rotate=90] {\parbox{0.25\frameheight}{\tiny\centering \lipsum[13]}};%
        %
        %Copyright notice English
        \node (copyright english) at ($(frame.north west)!0.25!(frame.south west)$) [content box, xshift=-1cm, rotate=90] {\parbox{0.25\frameheight}{\tiny\centering \lipsum[13]}};%
        %
        %Logo
        \node (logo) at (frame.north west) [content box,anchor=north west,outer sep=\padding] {\usebox{\logobox}};%
        %
        %Title
        \node (title) at ($(frame.north west)!\logowidthratio!(frame.north east)$) [content box,anchor=north west, outer sep=\padding] {\usebox{\titlebox}};%
        %
        %metadata metadata
        \node (metadata) at ($(frame.north west)!\logowidthratio+\titlewidthratio!(frame.north east)$) [content box,anchor=north west,outer sep=6pt] {\usebox{\metadatabox}};%
        %
        %Document number metadata
        \node (document number) at ($(frame.north west)!\logowidthratio+\titlewidthratio!(frame.north east)$) [content box,anchor=north west, yshift=-0.33\headerfirstrowheight,outer sep=6pt] {\usebox{\docnumbox}};%
        %
        %Revision metadata
        \node (revision) at ($(frame.north west)!\logowidthratio+\titlewidthratio!(frame.north east)$) [content box,anchor=north west, yshift=-0.66\headerfirstrowheight,outer sep=6pt] {\usebox{\revisionbox}};%
        %
        %Contract number metadata
        \node (contract number) at ($(frame.north west)-(0,\headerfirstrowheight)$) [content box,anchor=north west,outer sep=6pt] {\usebox{\contractnumbox}};%
        %
        %Project number metadata
        \node (project number) at ($(frame.north west)-(0,\headerfirstrowheight)$) [content box,anchor=north west,xshift=\logowidth,outer sep=6pt] {\usebox{\projectnumbox}};%
        %
        %Book number
        \node (book number) at ($(frame.north west)-(0,\headerfirstrowheight)$) [content box,anchor=north west,xshift=\logowidth+0.5\titlewidth,outer sep=6pt] {\usebox{\bookbox}};%
        %
        %Page number
        \node (page number) at ($(frame.north west)-(0,\headerfirstrowheight)$) [content box,anchor=north west,xshift=\logowidth+\titlewidth,outer sep=6pt] {Page: \thepage\ of \pageref{LastPage}};%
        %
        %
        % HEADER FAUX-TABLE GRID LINES
        %
        %
        %First header row horizontal bottom line
        \draw ($(frame.north west)-(0,\headerfirstrowheight)$) -- ($(frame.north east)-(0,\headerfirstrowheight)$);%
        %
        %Header horizontal bottom line
        \draw ($(frame.north west)-(0,\headerheight)$) -- ($(frame.north east)-(0,\headerheight)$);%
        %
        %Third header column, first row horizontal bottom line
        \draw ($($(frame.north west)!\logowidthratio+\titlewidthratio!(frame.north east)$)-(0,.33\headerfirstrowheight)$) -- ($(frame.north east)-(0,.33\headerfirstrowheight)$);%
        %
        %Third header column, second row horizontal bottom line
        \draw ($($(frame.north west)!\logowidthratio+\titlewidthratio!(frame.north east)$)-(0,.66\headerfirstrowheight)$) -- ($(frame.north east)-(0,.66\headerfirstrowheight)$);%
        %
        %First header column vertical right line
        \draw ($(frame.north west)!\logowidthratio!(frame.north east)$) -- ($(frame.north west)!\logowidthratio!(frame.north east) - (0,\headerheight)$);%
        %
        %Second header column vertical right line
        \draw ($(frame.north west)!\logowidthratio+\titlewidthratio!(frame.north east) - (0,\headerheight)$) -- ($(frame.north west)!\logowidthratio+\titlewidthratio!(frame.north east)$);%
        %
        %Second header row middle vertical
        \draw ($(frame.north west)+(\logowidth+0.5\titlewidth,-\headerfirstrowheight)$) -- ($(frame.north west)+(\logowidth+0.5\titlewidth,-\headerheight)$);%
        \end{tikzpicture}%
    }
}
share|improve this answer
    
Rather than creating the header using tikz, why not use a simple table as the header? –  Aditya Feb 25 '11 at 19:51
    
I had problems with finetuning a table to my requirements (tex.stackexchange.com/questions/12030/table-cell-overflow). –  ipavlic Feb 26 '11 at 11:22
    
It's great that you post an answer showing how far you got. However, it's really discouraged to ask questions in an answer, and you probably won't get any answers this way. So it would be best if you just describe in this answer that this is how far you got, and then post a new question where you ask "Can it be done somehow, without resorting to everypage?". In this new question you can put a link to this post to provide the background. –  Hendrik Vogt Mar 1 '11 at 11:42
    
Thank you Hendrik, I've already done that, but haven't removed the question here. I will do so now. –  ipavlic Mar 1 '11 at 12:20
    
Great, thanks! –  Hendrik Vogt Mar 1 '11 at 13:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.