1

I have written a python program that reads in columns from a spreadsheet and produces a feedback sheet in LaTeX for students like so:

enter image description here

The issue I have is that the number of columns is variable, and depends on the task I have chosen.

Sometimes, there are too many columns and the latex table produced therefore goes off the edge of the page:

enter image description here

Ideally, I would like latex to recognise that the table has exceeded the edge of the page and just continue it beneath.

Is there any way of doing this? Otherwise, I will need to write some code that will have to chop it up before hand, which is not ideal.

EDIT: the width of the table is unknown before hand: it depends on the number of questions and the description of the questions, hence a dynamic continuation automatically determined by LaTeX is better.

1
  • You know beforehand how many columns you need? So the Python script can produce any LaTeX code? Is uniform length ok for you? Are the tables of the form 3 rows everytime?
    – Skillmon
    Aug 19, 2017 at 13:25

2 Answers 2

2

Don't use one but many tabulars. Add \hspace{0pt} between the tabulars to get a break point, and use \raggedright:

\documentclass{article}
\textwidth=10cm
\begin{document}
\raggedright
\begin{tabular}{l}
\hline
Q1\\
Beta Decay Equation\\
\hline
yes\\\hline
\end{tabular}\hspace{0pt}%
\begin{tabular}{l}
\hline
Q1\\
Beta Decay Equation\\
\hline
yes\\\hline
\end{tabular}\hspace{0pt}%
\begin{tabular}{l}
\hline
Q1\\
Beta Decay Equation\\
\hline
yes\\\hline
\end{tabular}\hspace{0pt}%
\end{document}

enter image description here

1
  • This looks genius! Let me try this. Aug 19, 2017 at 13:33
0

If the form is always with 3 rows, you could as well change to vertical and use longtable:

\documentclass[]{article}

\usepackage{amssymb,longtable}

\begin{document}
\begin{longtable}{l|lc}
    Q1 & Beta Decay Equations & \checkmark\\
    Q2 & Alpha Decay Equations & \checkmark\\
    Q3 & Changes to the Nucleus & \checkmark
\end{longtable}
\end{document}

You must log in to answer this question.

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