[texhax] Documents with multi-line headers, and mostly a multi-page table contents

Donald Arseneau asnd at triumf.ca
Tue Apr 12 08:41:16 CEST 2011


Gordon Haverland <ghaverla at materialisations.com> writes:


You mean letterpaper, not letter, on documentclass

About the headheight: you measure the "height" of the vertically centered 
sbox, so you only get about half the height.  Your textheight is too big 
for the page with that header I think; you should subtract headheight
from it.

>  1) The upper-right rectangle should have the text near the right 
> border.  I can force this by inserting a hspace, but I think I 
> don't need to.  I don't understand why 'r' justification doesn't 
> place the text at the right.

You use tabularx for the inner table, but with no X column it 
never expands to fill the specified width.  You can use tabular
for the inner one and p{width} for the column in the outer
tabularx.  Or you can use tabular* for the inner one and center
it by inserting some !{\extracolsep{\fill}} and !{\extracolsep{0pt}}
directives.  Or, instead of an inner tablular of any sort, use 
the outer column template for alignment.  (Below, all three methods
are demonstrated!)

Hey, \extracolsep didn't work for a single column!  Why!?!? 
Replaced by option 4, centering and given width by \makebox.

>  1a) When I first started playing with this, the LastPage 
> reference worked.  Now it doesn't work (I just get ?? for 
> LastPage).

Because you use it before \begin{document}


>  2) The 3rd line contains 3 rectangular areas.  The right most 
> rectangle has the same problem as the first line.
>  3) The middle rectangle is supposed to be centered.

As for 1.  You give "c" for the piping?  Should it be "r"?

Note that the hyphen characters used as minus signs are incorrect.

>  4) The left rectangle has always started some distance below the 
> line that defines the box for the table.  I've never had tables do 
> this before, but I would like the content to start at the top of 
> the space, and not 1 or 2 lines down.

Because you are using tables within r entries of outer tables.  The
inner tables are vertically centered by default.  I also notice
some extra \\ at the end of tables, producing an extra blank line
at the bottom.  Make any inner tables with [t] for vertical alignment.

>  5) Running pdflatex multiple times, the hyperref link from a note 
> in the header (which will be on every page) doesn't resolve.

Because you use it before \begin{document}. But you can't use a
box and expect the page number inside it to change for every page!!
Even if you get the LastPage reference to work, it would still say
"Page 1 of" on every page.  Thus your header needs to be a macro
(newcommand) not a saved box. 

>  6) Quirk: it would be nice to have the same border width for the 
> double lines around the header box.

You have a bunch of uninteded space characters;  use comments to
hide them:

\sbox{\edochdr}{%
\fbox{%

...

  \vspace{0pt}
  \end{minipage}%
}%
}

...

\chead{%
  \usebox{\edochdr}%  EXCEPT WE WANT A MACRO, NOT A BOX.
}

Also, your width measurements don't make sense to me!  I think you 
really intended to use:


\setlength{\msinnerbox}{\textwidth}
\addtolength{\msinnerbox}{-2\fboxsep}
\addtolength{\msinnerbox}{-2\fboxrule}

\newsavebox{\edochdr}
\sbox{\edochdr}{%
\fbox{%
  \begin{minipage}{\msinnerbox}
     \begin{tabularx}{\msinnerbox}{|X|m{0.2\msinnerbox}|}

Note the difference in arithmetic, and the minipage is now
the same width as the tabularx inside.  I also made it [b]
and put \vspace{0pt} at the end of it so that it is fully
bottom-aligned, all so that the measured "height" is the
total height.

The vertical separation of your three tabularx is not right.
Between the two with double rule, you should give a separation
of \fboxsep (because that's the separation around the edge),
using:  \par\nointerlineskip\vspace{\fboxsep}
For the join with just a single rule, they shpuld touch:
\par\nointerlineskip


> A couple of "minimal" files are below.


\documentclass[11pt,letterpaper,oneside]{report}

\usepackage{tabularx}
\usepackage{textcomp}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{ltxtable}
\usepackage{hyperref}


\setlength{\textwidth}{7.5in}
\setlength{\evensidemargin}{-0.75in}
\setlength{\oddsidemargin}{-0.75in}

\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}

\setlength{\tabcolsep}{2pt}

\setlength{\fboxsep}{2pt}
\newlength{\msinnerbox}
\setlength{\msinnerbox}{\textwidth}
\addtolength{\msinnerbox}{-2\fboxsep}
\addtolength{\msinnerbox}{-2\fboxrule}

\newcommand\edochdr{%
\fbox{%
   \begin{minipage}[b]{\msinnerbox}
   \begin{tabularx}{\msinnerbox}{|X|m{0.2\msinnerbox}|}
      \hline
      EngineeringLetterhead & 
         \raggedleft % METHOD OF NO NESTED TABULAR
              {\large{\bf A}}\linebreak % emphasize which meaning of \\
              Rev. 3\linebreak 
              January, 2009\linebreak 
              \thepage~of~\pageref{LastPage}
          \tabularnewline
      \hline
    \end{tabularx}
\par\nointerlineskip\vspace{\fboxsep}
    \begin{tabularx}{\msinnerbox}{|X|} \hline
      \begin{center}
        {\large{\bf Piping Material Specification}}
      \end{center}
    \end{tabularx}
\par\nointerlineskip
    \begin{tabularx}{\msinnerbox}{|X|p{0.30\msinnerbox}|r|}
     \hline
      {\bf Some title\newline}
      Some really long content that just goes on forever.  But
      what is it really?  I don't know. \vfill
          & \centering % METHOD OF NESTED CENTERED TABULAR
            \begin{tabular}[t]{rrcrr}
              \multicolumn{5}{c}{\bf Pressure Limits} \\
              1965       & kPa      & @ &       -29 & \textdegree{C} \\
              {\sl 280} & {\sl psi} & @ & {\sl -20} & {\sl \textdegree{F}} \\
              1172       & kPa      & @ &       260 & \textdegree{C} \\
              {\sl 170} & {\sl psi} & @ & {\sl 500} & {\sl \textdegree{F}}
            \end{tabular}
           & 
              % METHOD OF MAKEBOX
              \makebox[0.20\msinnerbox]{%
                \begin{tabular}[t]{c}
                  {\bf B31.3 Piping} \\
                  Class \\
                  {\bf 150} \\
                  ASME
                \end{tabular}%
             }
          \\
      Note: 1\ref{n:1} & & \\
      \hline
    \end{tabularx}

    \begin{tabularx}{\msinnerbox}{|X|X|X|} \hline
      CA: 1.6mm ({\sl 0.0625in\/}) &
        PWHT: Code &
          Tubing Class: CLC \\
      Radiography: 10\% &
        Material Group: 1.1 &
          Branch Table: 1 \\
      \hline
    \end{tabularx}%
\end{minipage}%
}%
}

\errorcontextlines 999


\newlength{\msheadheight}
\settoheight{\msheadheight}{\edochdr}
\setlength{\headheight}{\msheadheight}
\addtolength{\textheight}{-\msheadheight}

\chead{\edochdr}

\renewcommand{\headrulewidth}{0pt}

\setlength{\textheight}{10.0in}
\setlength{\topmargin}{-0.5in}

\addtolength{\textheight}{-\msheadheight}

\begin{document}


\LTXtable{\textwidth}{gtable.tex}

\noindent
\begin{tabularx}{\msinnerbox}{X} \hline
 {\label{n:1}1: This is note 1.} \\
 {\label{n:2}2: This is note 2.} \\
\end{tabularx}


\vfill

Bottom of page



\end{document}


-- 
Donald Arseneau                          asnd at triumf.ca


More information about the texhax mailing list