6

Whenever I try to learn more about TeX or LaTeX, I am stymied by the general bias of the books and online resources I have seen, and possibly by the bias of LaTeX itself. I am not interested in using TeX to typeset books, articles, slides, or journal publications. Instead, I would like to use it for documents that other programs generate. These documents are not of a technical nature.

For example I have a system written in Haskell that takes cooking recipes and generates grocery lists. I need to generate printed output for the recipes and the grocery lists. This of course is not a book or article, and because the output is being generated automatically I don't care about separating presentation and content. Instead my main concern is making the printed output look good. So far I am using roff for this because I have never managed to figure out how to use (La)TeX for something like this.

Another thing that I would like to write is a simple system to take checklists written with very little markup and transform them to a good two-column layout for printing.

What good resources exist for learning (La)TeX if you do not want to write a long structured technical document? It seems that TeX is a typesetting program like roff, so it should be possible to use it for things like this, but I don't know where to start learning. Everything I read starts out with how to write an article.

5
  • 1
    Welcome to TeX.sx! Feel free to visit our TeX.SX starter guide. May 26, 2013 at 16:20
  • 5
    this question might better be phrased as "how to learn to use TeX to produce documents from automatically-generated content?" May 26, 2013 at 17:11
  • I can relate to what you are going through but the only way to proceed is to start with a document using for example the article class and determine how you want to: 1. Do the layout, 2. To specify what is in the output. Once you have that, you can generate the desired code to produce what you want. But unless you make an initial attempt with a basic document you are not going to be able to get to the next step. So, make an attempt and post a specific question about what you are stuck on. Also, don't get stuck on the fact that you are generating a article - it's just a document. May 26, 2013 at 18:07
  • @Omari Norman I almost posted an answer suggesting that you use Troff instead of TeX before noticing that you are actually use Troff. So which particular aspect of your current solution involving Troff you do not like and would like to improve? TeX is at this time more capable typesetting system than Troff and with huge user base comparing to Troff but beautiful output is definitely possible with Troff as well. Based on your expressed needs if I was you I would stick it to Troff as learning new typesetting system is huge investment in time which needs clear justification. May 26, 2013 at 23:47
  • I think LaTeX is very geared towards documents in the style of scientific articles or books: a one- or several-column type area in the middle, footnotes below, headers on top, and margin notes to the side - that kind of thing. It's in some sense a legacy of a similar, but less pronounced bias in TeX, with its "main vertical list" and output routine. To overcome this, I developed a "document design" system (on top of TeX) with the specific purpose of making it easy to design any kind of document - docscape.de May 27, 2013 at 3:05

2 Answers 2

3

The question is general, but the cited example is pretty specific. Separation of form and content is actually very useful if the documents are generated automatically. In your case, I think a 'master file' plus 'content file' makes the most sense. Have your list generated as plainly as possible, call it grocery-list.tex (say), and make it look like this:

% grocery-list.tex
\item Apples
\item Oranges
\item ...

Then you want simply to \input that file into another one that controls the formal layout of the page. You could do something like this (let's call this grocery-master.tex):

\documentclass[12pt, oneside]{article}
% does a grocery list require indented paragraphs?
\parindent 0pt
% set encoding stuff
\usepackage[T1]{fontenc}%
\usepackage[utf8]{inputenc}%
% pick a font:
\usepackage[fulloldstylenums,largesmallcaps]{kpfonts}%
% maximize space for text given there is no need for
% any header or footer in a grocery list
\usepackage[margin=2cm,noheadfoot]{geometry}
% probably want a two-column layout
\usepackage{multicol}

% you actually do want to separate form and content,
% even if (especially if?) you are generating the document
% from another program. Here is one simplistic example
\newcommand{\headlinefont}{\large\bfseries\sffamily}
\newcommand{\headline}[1]{%
  \begingroup\headlinefont% <-- now all content generated by the \headline command will be the same
  #1\endgroup}
\begin{document}
\begin{multicols}{2}

\headline{My <whatever> list}

\begin{itemize}

\input grocery-list.tex

\end{itemize}
\end{multicols}
\end{document}

Only you will be able to decide what a 'good two-column layout for printing' looks like, but this should get you started. For customizing lists, I recommend the enumitem package. For fancier font stuff, remove the first three \usepackage lines, replace with \usepackage{fontspec}, pick your fonts, and use either the LuaTeX or XeTeX engines (commands: lualatex or xelatex). There is also ConTeXt instead of LaTeX, which would be ideal for this sort of thing (I think); hopefully someone posts a simple example for you to try. For specific questions related to specific issues, simply ask more (i.e., new) questions on this site.

Cookbooks would definitely be more complicated, but the same principles apply.

2

Your question is rather general, so also an answer is.

Learning how to write an article (without mathematics) is a good starting point to more advanced forms. Then you can easily use, e.g., packages for recipies: A cookbook in LaTeX?. Here http://www.gust.org.pl/bachotex/2006 (Halina Wątróbska, Ryszard Kubiak, From XML to TeX, using Emacs and Haskell) you can find an example of using Haskell and LaTeX to obtain a dictionary of Old Church Slavonic language.

3
  • Thank you. Is this the only conceivable way for beginners to do non-article documents--that is, rummage around and find a package that roughly fits what you want and try to hammer it into submission? This frustrates me because I would rather learn how to create my own documents from the ground up. Is that too hard? If anything, maybe I am trying to use TeX more like a word processor, as I do not care about this "separating content and presentation" that is so often presented as being desirable. Is it possible to use TeX in this way?
    – massysett
    May 26, 2013 at 18:03
  • @OmariNorman I had started from TeX, LaTeX was later, so I understand your attempt. On the other way, standard packages cover about 90% of my desires. Making one's own definitions and polishing them is rather time-consuming. And, as Peter Grill says, article needn't be for articles (and I am adding now: table for tables, picture for pictures and so on). May 26, 2013 at 18:18
  • @OmariNorman -- If you really want 'from the ground up', you should learn and use plain TeX. LaTeX is a macro package with thousands of 'add-on' packages designed to make your life easier. If you don't want easier, and want to understand everything happening 'under the hood', then plain (or eplain; try texdoc eplain in a terminal for more info) is the way to go!
    – jon
    May 26, 2013 at 21:51

You must log in to answer this question.

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