GeneralAutomatically calculate values of a large table

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
jrkirkish
Posts: 1
Joined: Fri Jun 04, 2010 8:37 am

Automatically calculate values of a large table

Post by jrkirkish »

LaTeX beginner here, but I've learned a lot from the copious documentation available online. There's one thing I haven't been able to figure out, though, and I don't even know if it is possible. If worse comes to worse, I'll just whip something out in C and copy & paste what I need (and in the process create a GIANT .tex document. I know there's got to be a more elegant solution.

I'd like to make a large document that would simply be a table of the time that the five major planets will rise (basically a large chart of the synonic cycles of the planets). This will be eventually be bound in a thick leather tome to be placed in my library filled with rich mahogany.

I've broken this down enough so that I can grasp the idea of how to do it. I'm missing the ability to apply this idea. All I would have to do is something like this, but longer:

Code: Select all

\begin{tabular}{ l l l }
  Date & Rise & Set \\
  x & y & z \\
  x+1 & y+1 & z+1 \\
  x+2 & y+2 & z+2 \\
\end{tabular}
I can't for the life of me figure out how to do variables that would do that in LaTeX. If anybody can even provide a starting point - again, if this is even possible - I'd be most grateful. So, LaTeX or C?

You can stop reading now, the following is just a justification of what I am doing and an attempt to show that I sort of know what I'm talking about.

Yes, I know a synodic day is different than a sidereal day, and yes, I know that that there will never be a time when all five major planets are in conjunction. I'll also throw in the set and rise times of different stars at different latitudes, and I know this doesn't really have any practicality. It's more of an art piece than anything else. I'm just a guy that can find something beautiful at looking at a table of the tides, or a ship's log book. Maybe I'm weird, but that's why I'm doing it.

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Automatically calculate values of a large table

Post by gmedina »

Hi,

you need a table spanning several pages; you can use, for example, the longtable or the supertabular packages (there are some other packages that you could use; search the CTAN archive). You seem to need some loops; the ifthen package, for example, offers the \whiledo command (the multido package could be another option).

A little example that perhaps you could use as a starting point:

Code: Select all

\documentclass{article}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{ifthen}

% counters for date, rise and set
\newcounter{tabdate}
\newcounter{tabrise}
\newcounter{tabset}
% a command to typeset each row
% it increases the counters and then typesets them and starts a new row
\newcommand\myrow{%
  \stepcounter{tabdate}%
  \stepcounter{tabrise}%
  \stepcounter{tabset}%
  \thetabdate & \thetabrise & \thetabset \\
}

% a counter for the loop
\newcounter{mycount}

\begin{document}

\begin{longtable}{lll}
  \toprule
  \textsc{Date} & \textsc{Rise} & \textsc{Set}\\
  \cmidrule(lr){1-1}\cmidrule(lr){2-2}\cmidrule(lr){3-3}
  \endhead
  \whiledo{\value{mycount}<200}
    {\stepcounter{mycount}\myrow}\\[-12pt]
  \bottomrule
\end{longtable}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply