Graphics, Figures & TablesAutomatically arranging many elements into columns

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Hopey
Posts: 1
Joined: Thu Oct 08, 2009 12:47 pm

Automatically arranging many elements into columns

Post by Hopey »

Hello.

I'm writing a program that automatically generates a pages of maths questions and outputs it as a tex file (which is then processed into a pdf).

Currently each 'element' is put into a simple table. (xtable actually, to allow it to span multiple pages.) This is simplistic, as each element is the same size and all are aligned in a rectangular grid.

What I want to do is as follows:

1) Produce each element as a self contained 'box' with a height and width (within some sensible range, e.g. between 1 and 5 cm or whatever). I won't know precisely what these dimensions are. (recall it's generated programmatically) Each will consist of some string of LaTeX enclosed in some appropriate thingo (\mbox{..} or whatever.)

2) Arrange these in columns on the page, in the given order, starting at the top left:
- if there's room below the previous one: put it there
- else if there's enough room to start a new column: start a new column
- else start a new page

The point is that when I put the thing together, I don't know exactly how many columns and rows there are going to be on the page. (Obviously each column will be as wide as its widest element, and go to a new page if there's not enough horizontal space, but these are fiddly bits to work out later.)

Part 1 I'm fine with, but part 2 I'm struggling with. How would I go about this?


To put it another way: Suppose one was using a regular word processor, and copied & pasted a bunch of images of various sizes, inserting them as text. One would go after the other until the row was full, the next would start a new row, until the page was full whereupon it would start a new page. That's what I want to do, except I want it to fill columns first, not rows; and the elements are 'boxes' of latex formatted whatnot, not images.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply