2

I want to layout some information in a structured, table-like, or form-like manner. Basically, each 'block' has multiple fields like Title, Description, and other things, and I want to display them like this:

enter image description here

I made this example in Word, where I used a complicated table structure. As you can see, each 'row' has a variable number of 'columns' and with different widths, so I don't think a table would work in LaTeX. The different cells also have different formatting.

I have a few different ideas of how to do this, but I sort of feel they're all hacks rather than the "right answer". I would also prefer to separate presentation from content, and to be able to tweak the presentation later with additional fields/different spacing.

How should I go about doing this?

2 Answers 2

1

For this sort of problem is always good to start from the input, i.e., your user interface especially if is to typed in by a human. If the data is to be generated by a computer then one need not worry too much about this. It is always good to simplify and define your structure first. In your case it has a simple structure and I would go for an input such as this:

\title This is the Title;  
\infoi This is the first info block ;
\infoii This is the second info block ;
\texti This is the first text block;
\textii This is the second text block;
\textiii This is the third text block;

If you fond of curly brackets you can re-define the minimal at the bottom and use them, however if you have a lot of capturing to do, this can become cumbersome.

\title{This is the Title}  
\infoi{This is the first info block}

It is good to separate the concerns as well as presentation from data. For Presentation, you can program a macro \render. I would use minipages or parboxes throughout of fixed width or any of the other boxing macros available. In the example, I have used simple fboxes just to illustrate the technique. Please also note that I have used through \def rather than \newcommand for clarity. Please replace if you feel uncomfortable using \defs.

\documentclass{article}
\makeatletter
\newenvironment{blockquote}{
   \bgroup
   \parskip0pt
   \def\title##1;{\def\@title{##1}}
   \def\infoi##1;{\def\@infoi{##1  }}
   \def\infoii##1;{\def\@infoii{##1}}
   \def\texti##1;{\def\@texti{##1}}
   \def\textii##1;{\def\@textii{##1}}
   \def\textiii##1;{\def\@textiii{##1}}
   \def\render{\fbox{\@title}\par
                     \fbox{\@infoi \@infoii}\par
                     \fbox{\@textii}\par
                     \fbox{\@textii}\par
                     \fbox{\@textiii} %
    }
}{\egroup
}

\makeatother
\begin{document}

\blockquote
\title This is the Title;  
\infoi This is the first info block ;
\infoii This is the second info block ;
\texti This is the first text block;
\textii This is the second text block;
\textiii This is the third text block;
\render
\endblockquote

\end{document}

Note the \render work does all the donkey work for the presentational aspects of the code. This you need to spent time to define as you want it to look.

0
  1. Think of all possibilities for the different rows.
  2. Structure the rows. (Title, Subtitle/Description, Items,…)
  3. Find out, what are the parameters and what are the arguments of the different rows. (Arguments are, what usually differs from row to row, even if they are of the same kind. [In your example the "Blah blah".] Parameters are, what is usually the same for the same kind of row. [In your example maybe the "Text 1",…, as well as the formatting properties [Blue background, font issues, width of gaps/offsets])
  4. Structure the inheritance of the parameters according to the structure from 2.
  5. TeX it by
    • macros for the single rows
    • macros for the parameters, that are called inside the row macros
    • macros for the different kinds of rows, that change the parameter macros accordingly

or by

  • using existing packages to work with optional parameters (pgfkeys, xkeyval, xparse, …)

You must log in to answer this question.

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