# Reproducing a tabular form

I am trying to reproduce the following tabular form layout:

Fig. 1: Desired output (found on the internet).

First question:

I can merge multiple cells into a single one both horizontally and vertically (using \multicolumn and \multirow), but I do not know how to split a single cell into multiple ones. How can I do that?

Minimal working example:

\documentclass[11pt, a4paper]{article}
\usepackage{lmodern}
\usepackage{array}
\usepackage{tabularx}
\begin{document}

\scriptsize
\setlength{\extrarowheight}{0.2em}
\noindent\begin{tabularx}{\textwidth}{!{\vrule width 1pt}p{4cm} | X !{\vrule width 1pt}}
\noalign{\hrule height 1pt}
Question one & Question two\\[0.5cm] \hline
Question three & Question four\\[1cm] \noalign{\hrule height 1pt}
Question five & Question six\\[0.5cm] \hline
\multicolumn{2}{!{\vrule width 1pt} l !{\vrule width 1pt}}{Question seven}\\[1cm]
\noalign{\hrule height 1pt}
\end{tabularx}

\end{document}


I am able to seamlessly connect two tables using \vskip-0.7mm, but it would have to be adjusted after many various changes, e.g. font size, so I prefer a single table solution.

Edit (31 July 2011):

Fig. 2: Another tabular or tabularx inside a cell does not give a satisfying result.

Fig. 3: Problem with vertical alignment of the X column of tabularx.

The relevant part of the code:

\begin{tabularx}{\textwidth}{|p{4cm}|X|}
\hline
{\begin{tabularx}{\linewidth}{@{} l | X @{}}
Some text & Other text\\[1cm]
\end{tabularx}} & Something else\\
\hline
\end{tabularx}

-
@xport What do you mean? I do not know whether the certificate is a sample or actual, if that is what you mean. I have found it on the internet (accessible through Google Images). And do not delete your comments, it is confusing. – Harold Cavendish Jul 30 '11 at 21:18
What code reproduces Fig 2, since a minimal example similar to the 'relevant part of the code' pasted above does not have a problem with the spacing around the nested tabularx. – Werner Jul 31 '11 at 14:58
@Werner pastebin.com/Bg2QWgPj (Expiration set to one month.) Edit: There is a minor difference, I am sorry for that. Line 16 should end with [1cm]. – Harold Cavendish Jul 31 '11 at 17:37

1. Splitting cells: you can nest tabular environments. Just use a tabular like environment in a cell. If you nest tabularx environments, it can be helpful to enclose an inner tabularx environment by braces.

2. Rotating content: you could use \rotatebox of the graphicx package, see Changing text direction in LaTeX table capabilities.

-
1. I have tried it but the output is not satisfying because it leaves free space on three sides and I am not able to remove it (screenshot in the edited question). 2. I have used the same before, but it exceeded the boundaries of the table so I was hoping for an automatic solution without the need to adjust every cell. The hyperlink is nevertheless very useful, thank you. – Harold Cavendish Jul 31 '11 at 9:44
@Harrold: 1. You could remove space by @{} at the sides. Instead of nesting, you could refine the table and merge more. 2. The array package feature >{...} is good for making automatic. But perhaps you can see now that it would be good to post 2 questions as 2 questions, not mixed as one (just because of the same background). How can I produce a column with rotated text in all cells would have been a good question on its own. – Stefan Kottwitz Jul 31 '11 at 10:42
@{} eliminated the space on the left and on the right and I have also removed \extrarowheight so there is no space on top, but if I adust the height of the cell by \\[height] in order to fill the whole cell which is to be divided (the line would otherwise be too short), the text in the cell on the right is not vertically aligned to the top any more (the X column of tabularx). I have again added an image to illustrate the current state. Should I separate the two questions at this point? – Harold Cavendish Jul 31 '11 at 11:03
@Harrold: yes, it would be better to split a complex problem into several specific questions. It fits better to a Q&A site, since it doesn't work like a discussion forum. And the site likes well written questions. – Stefan Kottwitz Jul 31 '11 at 11:48
Done. Some more words to be able to post the comment. – Harold Cavendish Jul 31 '11 at 13:22

Why do you like to reproduce the tabular form layout?

I had a similar problem in the past, my solution was quite easy: Scan the form into a pdf and use pdfpages to load it as background image (or if available: take the pdf of an empty form).

Then I defined some macros to fill text at the correct positions into the form in page background. If you like, I can provide my style (I hope I find it ;-) )

-
There is no package for creating forms that I am satisfied with, so I am making my own. I need to produce own forms from scratch. Unlike you, I need to produce an empty form which will then be filled in by hand or by additional printing. Nevertheless, thank you for your offer. – Harold Cavendish Jul 30 '11 at 21:42
Ok, then you need really another solution. One more question: Did you take a look to the picture environment? You may fix a picture in a corner and draw lines to build the form. It's a pain to build the form, but you will have less problems with relative positions. You may fix elements and continue with the next elements. – knut Jul 30 '11 at 22:42
Yes, I have and exactly as you say, it is a pain to work with on this task. Then, I want to be able to easily change e.g. the height of the columns or other parameters. – Harold Cavendish Jul 31 '11 at 9:53

The best solution for dividing columns as in this case that I have found is the following:

\documentclass[11pt, a4paper]{article}
\usepackage{lmodern}
\usepackage{array}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\begin{document}

\rowcolors{1}{black!10}{white}

\scriptsize
\setlength{\extrarowheight}{0em}
\begin{tabularx}{\textwidth}{|p{4cm}|X|} \hline
Question one & Question two\\[0.5cm] \hline
Question three & Question four\\[1cm] \hline
Question five & Question six\\[0.5cm] \hline
{\begin{tabularx}{\linewidth}{@{} l | X @{}}
Some text & Other text\\[1cm]
\end{tabularx}} & \raisebox{0.5cm}{Something else}\\
\hline
\end{tabularx}

\end{document}


The height of the whole row is determined by the height of the row of the inner table and since the text in the same row of the outer table is vertically centered, it is then raised by a half of the inner row height, in this case [1cm] and \raisebox{0.5cm}{...}.

Joining tables with \vskip-(number)(em/ex) is possibly even better, but my original requirement does not allow this.

If you are going to vote for this answer, you should consider voting for Stefan's as well, as the majority of the unwanted space was eliminated by him. This is only to provide the definite answer for the possible future use by other persons.

-