3

You're dealing with a complete LaTeX noob here, so please be gentile ;) I'm trying to typeset a particular lay-out, but I've not been able to get the desired result so far. My previous attempt was in MS Word, where I've come to the conclusion that it just wasn't up to this task, finally seeing a good excuse to dip my toes into LaTeX. I think I've come a long way so far with LaTeX during the last couple hours, but wonder if what I want is even possible right now, therefore asking for advice here before I spend a lot of extra fruitless hours on this. But I'm probably tackling it from an xy-question approach :)

My desired lay-out is to create a 'two-column' block macro, where the narrow left column essentially contains a title rotated 90 degrees with a background color, vertically spanning the content to it's right, and the right column takes up the rest of the page width containing the content. These blocks must be able to nest; i.e. I must be able to place such a block as a sub-block inside the left column's content. The nesting must be able to go to the 3rd layer (but a general approach would be better). And it must also be able to break mid-way and continue on the next page.
To illustrate what I want, I've included a MWE at the end which almost wants what I want (apart from the page breaking).

Complicating factors are:

  • I want the left 'heading' column to have some line art directly above the rotated header text, and some other line art right at the bottom of the column, effectively making an arrow of the left column.
  • I want the left column to continue on next pages if the content of the right content column stretches over a page border, effectively giving a colored (empty) band on following pages in the left margin.
  • The whole construct also shouldn't be pushed to a new page when becoming too big - I want it to start right where I place it, and break it's content to the next page where applicable. The page breaking should not be manual, since the content of the blocks will be generated programmatically and can vary in size significantly.
  • Also, when flowing over to the next page, the split may appear anywhere in the content column, but of course not half-way through the header text itself (the header texts will always fit on a page, so if the header cannot be placed fully on a page the block should be flowed to the next page).

I've tried tabular, but found out I get everything to work apart from the breaking on page borders (see the MWE). longtable also didn't cut it; it only splits between rows and not inside of a row. multicols doesn't allow me to set the column widths, and with parcolumns I just couldn't get the lay-out right.

I'm working on Windows btw (using MiKTeX and TeXnicCenter), generating PDF's, but I guess that shouldn't matter.

If anyone could point me to any other constructs I can use that could make such a design possible, I'd be very grateful!

Here's the MWE. Don't know if it's an eye-sore to more proficient LaTeX users, but I've tried my best ;)

\documentclass[11pt,twoside,a4paper,notitlepage]{book}

\usepackage{array}
\usepackage[table]{xcolor}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{rotating}
\usepackage[none]{hyphenat} % prevent hypenation

% accent color
\definecolor{mycolor}{RGB}{98,127,27}

% sideheader arrow line art
\tikzset{
  startarrow/.pic={
    \fill[mycolor] (0cm,0.25cm) -- (0.25cm,0cm) -- (0.5cm,0.25cm) -- (0.5cm,0cm) -- (0cm,0cm) -- cycle;
  }
}
\tikzset{
  endarrow/.pic={
    \fill[mycolor] (0cm,0.25cm) -- (0.5cm,0.25cm) -- (0.25cm,0cm) -- cycle;
  }
}

% single block
\newlength\contentwidth
\newcommand{\mytable}[3]{{
  \setlength\contentwidth{\hsize}
  \addtolength\contentwidth{-0.8cm}
  \def\arraystretch{0}
  \setlength{\tabcolsep}{0.0cm}
  \begin{tabular}{p{0.5cm}@{\hspace{0.3cm}}p{\contentwidth}}
    \tikz \pic{startarrow}; & \\
    \cellcolor{mycolor} \centering {\rotatebox[origin=r]{90}{#2}} & \raggedright\arraybackslash #3\\
    \tikz \pic{endarrow}; & \\
  \end{tabular}
  \let\contentwidth\undefined
}}

\begin{document}

\mytable{1}{Caption of cell1}{\lipsum[1]}
\mytable{1}{Caption of cell2}{\lipsum[2]
  \mytable{2}{Caption of cell3}{\lipsum[3]
    \mytable{3}{Caption of cell4}{\lipsum[4]}
    \mytable{3}{Caption of cell5}{\lipsum[5]}
    \mytable{3}{Caption of cell6}{\lipsum[6]}
    \mytable{3}{Caption of cell7}{\lipsum[7]}
  }
}

\end{document}
  • i didn't think i saw a description of what you want to happen when the "header" is too long for the space available on the page. (you did say "the split may appear anywhere in the content column, but of course not half-way through the header text itself.") please be more specific about that (or point out where you said it in your question). – barbara beeton Jun 29 '17 at 12:18
  • @barbarabeeton: good point; I've edited the post. In practice header texts will always be relatively short, so they should always fit a page. It's more that when a header text spans e.g. 6 content lines, I do not want to have the page split on content line 3, resulting in the header text to be split 50/50 over the pages (thus becoming unreadable). In that case it's better if the whole block would flow to the next page. – Carl Colijn Jun 29 '17 at 12:28
  • As a general note: I'm not too interested in the specifics here; it's just that I want to know if there's a LaTeX construct that could allow for such a lay-out. The lay-out isn't sacred to me, it's just that I wonder if I could cobble something like that together using LaTeX. Pointers to usable candidate constructs are thus more what I'm after. – Carl Colijn Jun 29 '17 at 12:31
  • if the header text will always be rather short, and you can put a limit on its length, then '\needspace' might be workable. you'd also need to decide then whether to leave the page short (\raggedbottom) or stretch the remaining content (\flushbottom, the default). – barbara beeton Jun 29 '17 at 12:32
  • @barbarabeeton: from what I just read about \needspace and \raggedbottom these should indeed help with page breaking in the right locations. However, as of now the main problem is still that I haven't yet found a usable construct that is able to span over page boundaries at all :) – Carl Colijn Jun 29 '17 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.