2

I'm trying to create a header to go across a set of office documents; I tried to use the widetable package with multirow, but that didn't work. Here's the closest I've come so far, using http://www.tablesgenerator.com/ and the diagbox package:

\documentclass[a4paper,twoside,10pt]{report}
\usepackage{diagbox}
\usepackage{multirow}

\begin{document}

\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{lllll}
\hline
\multicolumn{1}{|l|}{\multirow{2}{*}{Model Effectivity}} & \multicolumn{4}{c|}{REVISIONS}                                                                                                   \\ \cline{2-5} 
\multicolumn{1}{|l|}{}                                   & \multicolumn{1}{l|}{REV} & \multicolumn{1}{l|}{DESCRIPTION}     & \multicolumn{1}{l|}{DATE}     & \multicolumn{1}{l|}{APPROVED}  \\ \hline
\multicolumn{1}{|l|}{\diagbox[dir=NE]{\hspace{35pt} }{ \hspace{35pt}}}                          & \multicolumn{1}{l|}{-}   & \multicolumn{1}{l|}{Initial Release} & \multicolumn{1}{l|}{1/1/2016} & \multicolumn{1}{l|}{Travis} \\ \hline
                                                         &                          &                                      &                               
\end{tabular}
\end{table}


\end{document}

I need to tweak the vbox dimensions on the rows as well - the I had to use diagbox to get the diagonal box I wanted (seems obvious, right?) but it wouldn't go to the corner properly unless I added the hspace elements, which made that box too tall.

How can I get that diagonal slash and a wide table to coexist peacefully (without having to resort to trying to draw it in Tikz)?

Edit: I'm trying to span a much larger percentage of the width of the page than the other questions, I think - however, this is a pretty common type of "header" (not in the LaTeX sense) that is found on engineering documents.

I'm adding a similar image: there's quite a bit of blank space in it (so that later, the description of changes can have a few words about what was changed, or what ECO was incorporated. Wide header on document

[Edit 2] So I tried to force the widths to work out the way I wanted using eqsetminwidth, then used adjustwidth to bring the table back to center (by manually moving it around - which is not elegant at all, but at least it's the right idea!). Now just have to figure out why it has those vertical lines under the first column... A wide header

\documentclass[a4paper,twoside,10pt]{report}
\usepackage{diagbox}
\usepackage{array, multirow, caption}
\usepackage{eqparbox}
\usepackage{adjustbox}
%\usepackage[showframe=true]{geometry}
\usepackage{changepage}

\makeatletter
\newcommand*{\centerfloat}{%
  \parindent \z@
  \leftskip \z@ \@plus 1fil \@minus \textwidth
  \rightskip\leftskip
  \parfillskip \z@skip}
\makeatother

\begin{document}
%\eqsetminwidth{<tag>}{<width>}
\eqsetminwidth{R}{4.5in}
\eqsetminwidth{D}{3.5in}
%\begin{adjustbox}{center}
\begin{table}[!htb]
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
%\centerfloat
%\noindent
\begin{adjustwidth}{-1.75cm}{}
  \centering\renewcommand\arraystretch{1.333}
%  \caption{My caption}
%  \label{my-label}
  \begin{tabular}{|*{5}{c|}}
    \hline
    \multicolumn{1}{|c|}{\multirow{2}{*}{\eqmakebox[H]{Model Effectivity}}} & \multicolumn{4}{c|}{\eqmakebox[R]{REVISIONS}} \\
    \cline{2-5}
                                                                                          & \multicolumn{1}{l|}{REV} & \eqmakebox[D]{DESCRIPTION} & DATE & APPROVED \\
    \hline
    \diagbox[dir=NE, width =\dimexpr\eqboxwidth{H} + 2\tabcolsep\relax, height=0.6cm]{}{} & --- & Initial Release & 1/1/2016 & Travis \\
    \hline

  \end{tabular}
\end{adjustwidth}   
\end{table}
%\end{adjustbox}

\end{document} 
trayres
  • 187
  • 5
  • What do you mean by a 'header'? This is not a header in LaTeX's sense. And why is this tagged tikz-pgf given that the question specifically excludes solutions using this package? – cfr Jan 05 '16 at 23:32
  • I suppose it isn't a header in the LaTeX sense, and sorry, I had just spent a lot of time looking at the tikz solution, it is mistagged.

    Edit: Fixed the tag. Thanks for the heads up!

    – trayres Jan 05 '16 at 23:41
  • Have you looked at - I think it is called makecell? – cfr Jan 05 '16 at 23:45
  • makecell can do lots of things with tables, including diagonal cells and much more. It might give you a more coherent interface than patching something together using different packages, for example. – cfr Jan 05 '16 at 23:48
  • I haven't tried makecell, I'll get it's documentation and give it a shot; thanks @cfr! – trayres Jan 05 '16 at 23:49
  • I was looking for something to span nearly the width of the paper on on the top - I thought diagbox wouldn't allow that. – trayres Jan 06 '16 at 00:01
  • @trayres I don't see why it wouldn't. Have you given it a try? – Sean Allred Jan 06 '16 at 01:18

1 Answers1

1

Here you are: I used the eqparbox package to measure the width of first column head, and set the width of the \diagbox to that width. I also simplified your code, and removed all the useless \multicolumns. Finally I loaded the caption package to get a decent vertical distance between caption and table:

\documentclass[a4paper,twoside,10pt]{report}
\usepackage{diagbox}
\usepackage{array, multirow, caption}
\usepackage{eqparbox}

\begin{document}

\begin{table}[!htb]
  \centering\renewcommand\arraystretch{1.333}
  \caption{My caption}
  \label{my-label}
  \begin{tabular}{|*{5}{l|}}
    \hline
    \multicolumn{1}{|l|}{\multirow{2}{*}{\eqmakebox[H]{Model Effectivity}}} & \multicolumn{4}{c|}{REVISIONS} \\
    \cline{2-5}
                                                                                          & \multicolumn{1}{l|}{REV} & DESCRIPTION & DATE & APPROVED \\
    \hline
    \diagbox[dir=NE, width =\dimexpr\eqboxwidth{H} + 2\tabcolsep\relax, height=0.6cm]{}{} & --- & Initial Release & 1/1/2016 & Travis \\
    \hline
  \end{tabular}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350
  • This looks brilliant, I just can't seem to force it to span more of the width of the page – trayres Jan 06 '16 at 00:17
  • 2
    What do you mean exactly with ‘span more of the width of the page’? – Bernard Jan 06 '16 at 00:23
  • I used eqsetminwidth and tags to make certain entries wider, then moved it left with adjustwidth - thanks for pointing me to eqparbox! – trayres Jan 06 '16 at 02:23