Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm a LaTeX beginner and am wondering what a typical workflow looks like when writing a (longish) document.

The draw for me is the ability to separate content and presentation, but it still seems like you need to know enough markup for sectioning and basic formatting, ie. italic, bold, etc. Do people write directly with LaTeX, or go through afterwards and mark things up?

Similarly, are authors thinking about how to structure multiple chapter files from the beginning, or is this generally done at the end phase, alongside page layout? (In this case I was looking at the Memoir package.)

So if an author is about to start a book, is it reasonable to just give them a limited number of formatting and section commands to work through the book, then at the end give them the big manual to dive in?

share|improve this question
8  
"So if an author is about to start a book, is it reasonable to just give them a limited number of formatting and section commands to work through the book, then at the end give them the big manual to dive in?" Adding the format at the end is IMHO more work than adding it while you type. At least the sectioning commands and local fonts changes (\textit etc.) should be done on-the-fly. Some early info like "If you want to start a chapter use \chapter{<text>}. If you want to use italic text use \textit{<text>}." should be easily understood, I think. –  Martin Scharrer Jul 6 '11 at 7:08
    
Related to tex.stackexchange.com/questions/19263/… –  N.N. Jul 6 '11 at 8:40
9  
@Martin: I agree, except that it should be: "If you want to emphasize text, use \emph{}." Otherwise you break the content/presentation separation. –  Caramdir Jul 6 '11 at 10:03

5 Answers 5

up vote 58 down vote accepted

Having written numerous documents of all lengths (from short letters, through to 'books' in excess of 100 pages- perhaps worth noting that I've not used a word-processor at all in years), my suggestion is that the beauty of LaTeX is to avoid most manual typesetting. When I start a longer document, I typically take the following approach:

  • Setup a LaTeX file for my overall book, writing any preamble that I'm sure I'm going to require.
  • Roughly draft the book into chapters, splitting each new chapter into its own file - a single large LaTeX file is far too large and unwieldy for a large project. These files are then included in my main file. (As an aside, I typically comment out all the includes but the one I'm working on at any given time.)
  • I then write the chapters, including any special formatting as I write. If I don't do it then, I typically forget where it goes. As a beginner, this may require you to compile the document repeatedly to make sure you're getting the desired output. As you become more experienced, you will do less of this.
  • Depending on the nature of the project, the first guess at choosing chapters may or may not be correct, it's easy to add and remove as you go along, so this may be required.
  • Once I'm finished writing, I return to fix any more significant problems, things like overfull hboxes, and tweaking the location of images if LaTeX hasn't quite done what I want.
  • Once this is done, I can return to the preamble and make any changes to finalise the document, generate the index, and other 'last minute' tasks.

In all cases, I try and limit the control I take from LaTeX to a minimum, if I wanted to typeset the item by hand I'd use something like InDesign. Typically this means using a good set of document classes, or a preamble that structures the document appropriately.

share|improve this answer
12  
+1 I totally agree on the split-chapters-across-files (-> \include) and "including any special formatting as I write. If I don't do it then, I typically forget where it goes." –  Martin Scharrer Jul 6 '11 at 7:10
4  
I'd also recommend using the standalone package for the chapters. That way you don't need to worry about commenting out the chapters you are not working on. –  Peter Grill Jul 6 '11 at 7:13
15  
Instead of commenting out use \includeonly, as it keeps the references to the other chapters intact. –  Caramdir Jul 6 '11 at 10:06
8  
I'd also throw in that things like cross-references and index statements are most easily put in while you're writing, particularly if you're going to be writing a technical document. Going back through everything to put in \index{} statements when you're done is quite a painful operation. –  David T. Macknet Jul 6 '11 at 10:32
10  
nice pice, the only thing that's missing is version control. –  Davy Landman Aug 12 '11 at 7:43

Preparation

I think that most people write and edit LaTeX directly (with more or less help from an editor) and that they compile their document often to see the result of changes. One advice I would like to give is to make a rough draft before starting to mess with LaTeX. Even if

authors should be able to focus on the content of what they are writing without being distracted by its visual presentation

is a tag-line of LaTeX it is not completely true. I often find myself adjusting layout instead of focusing on the content. Therefore I would like to suggest that you make a rough draft before you start to typeset in LaTeX. This could be to make a list of the ideas you want to use in the text as well as a rough disposition.

When writing

When you start to typeset in LaTeX I think it is efficient to use most of its power. Especially you will benefit from using commands to do cross-referencing (e.g. \label and \ref) and references to other works (like \cite or any other cite command from biblatex) as you write rather than at the end of the process. The same goes for quotes. If you decide to use csquotes it might be easier to mark up quotations as you write rather than later. Also if you are working with expressions that are repeated throughout the document you will benefit from using a method such as one described in Best way to avoid repeating expressions.

If you are writing a text with graphics that accompany your text, or if graphics is part of what you are presenting, you might benefit from making the graphics as you write rather than later. This enables you to make proper references to the graphics as well as making adjustment to the graphics to make it correlate with the text. However, note that it is often efficient to draft the graphics with pen and paper before you try to create it in LaTeX. When trying this it might seem to be counterproductive because it takes time to create graphics, especially if you are learning something like TikZ, but in visualizing your work you might discover things in your documents that needs to be changed and such things might be best to discover early in the process (it could be important changes in your theory).

Also, use tools that makes your work more efficient – use a good editor and version control – and automate when it is convenient. For example if you automate compilation by latexmk you will probably spend less time thinking about compilation and more time thinking about the content.

Finishing touches

There are things you can do late rather than early in the process. This is for instance to remove bad non-breaking spaces (~) and to create your title page. Checkout What are the finishing touches you put to a document? for more information on the late part of the process.


Implementation

One way to achieve a workflow like the one I described can be done by using Emacs. Here is how.

When drafting you can use Org-mode to outline your document. This is basically to make some headlines that represent content you want to include in your document and then you work by filling in content under each headline. The headlines are foldable so that you may get an overview of your document's structure. You can also mark the headlines with "DONE" or "TODO" to track your progress. See for instance this tutorial for details.

Once you are happy with a draft you can use Org-mode's export function to export the document to LaTeX (you can export from Org-mode with a preamble of your choice). I have written about this in detail in another answer. Then you can fine-tune the document with AUCTeX. Note that AUCTeX also has an outline feature for getting an overview of the document.

The idea for this approach is to take advantage of Org-mode's functions that eases the process of recording, organizing and developing ideas and also benefit from AUCTeX many functions that helps in editing LaTeX files. I believe that this is a good approach but it requires the user to know the basics of Emacs, Org-mode and AUCTeX. Fortunately there are good tutorials and manuals for them. One just need to know the basics, which are not hard to learn, to start out. Then one can learn the rest as one goes. For how to learn Emacs and some more notes on workflow see A simpleton's guide to (...)TeX workflow with emacs.

share|improve this answer
4  
I'd say that among the finishing touches is the removal of non-breaking spaces. It's better to have too many of them and the choice of removing one without spoiling the final result than chasing in a 300 page book for bad breaks. –  egreg Jul 6 '11 at 9:19
    
@egreg You're right. I've edited my answer accordingly. –  N.N. Jul 6 '11 at 9:28
    
One other thing to think about is that while most people do write directly in LaTeX, for some beginners, it is easier to start by using Lyx. It will certainly crop up at some point in time. I personally don't suggest it - because it makes terribly messy LaTeX, but it is easier for some people. –  Barns Jul 6 '11 at 11:02
    
@Barns I have added a note on how to efficiently outline a text without using LaTeX directly. –  N.N. Dec 28 '11 at 18:46
  1. Chose and/or make all the layout and style.
  2. Make a feature list and test examples.
  3. Draft on paper
  4. Write comments on what you mean
  5. Other things

  1. This is important, for example because text width determines how the equations are broken to new line, how the figures are placed and what sizes they have. Changing the text width, for example, may require a lot of manual rework. So, there are the choices in order of increasing complexity:
    • Get a style file from your publisher. For example look at Springer's Book Manuscript Guidelines. As in the above example, usually the publishers provide a class file, documentation on how to use it, and .tex file templates.
    • Use the memoir class for configurable typesetting. It's not possible to configure everything, but it's configurable to a reasonable level. It's well documented, but the documentation has many pages and requires time to read. Some aspects of the book typography are described also. Which makes the documentation usable even if you don't use memoir.
    • Go with ConTeXt. It's a lot more configurable than memoir but the documentation is even bigger. As far as I know, there are also some almost undocumented areas/features of it. And some things that can be done via external packages in LaTeX may not be easily possible in ConTeXt. (Here some ConTeXt user may give a better comment.)
    • Write your own class file. This requires considerable knowledge of the TeX/LaTeX's internals. It may, or may not be practical to learn it.
  2. This means identifying all typesetting features needed and their corresponding internal commands, or external commands used via package; and some good practices. Usually in the list go only the things the user is not yet familiar with. Than it's good to write the "list" in to a sample document for testing how the commands work. Some random examples:
    • Internal commands
      • Greek letter Phi has two variants - \phi φ, and \varphi ϕ. Also some other Greek letters have variants. And in different countries different variant is preferable on tradition basis.
    • External commands
      • For typesetting tensors, for example, there is a package tensor, which provides the commands \indices, \tensor, etc.
    • Features that are good practices and ideas
  3. I think, drafting directly in TeX/LaTeX is not as effective, as drafting on paper. Draft can be done, for example:
    • For the whole document at once
    • Chapter by chapter. Which means drafting a chapter, than writing in the code.
  4. If you can't do something, write a comment. "Here I want a chapter", or "Here a want a reference to the figure containing function q(w) graph", etc. At some point you will learn how to do that. Or will find that commenting gives you better content-presentation separation.
  5. Graphics go last. And a blank box with the same dimensions can be used to place a figure, before the figure is ready. Header, footer, table of contents, indexes are also switched on last. And probably other things.
share|improve this answer

In addition to the other tips, I'd like to make two comments, which are both related to my day-to-day editing and compiling of LaTeX documents.

The first comment I'd like to make is that using a folding editor may be a an equally good alternative to files. You can easily comment out folds or uncomment them, and they take up only little space in your input document. Furthermore, you can easily move folds around. If you don't know what a folding editor is, have a look at folding in vim. The following picture may also give you some idea. The picture is from LaTeX and Friends.

using the vim folding editor for LaTeX code

Having said that, I have to admit that I currently I don't use a folding editor for my day-to-day LaTeX. However, I did use an OCCAM folding editor some 18 years ago and I liked it. As soon as I've more time, I'll start using vim folds.

The second comment I'd like to make is that using files for chapters and sections also has another big advantage, especially if your editor supports easy line deletion and line restoration. The advantage I'd like to point out is that this technique really lets you write your document in a top-down fashion and lets you play with the order of presentation.

How this works is as follows. (For simplicity I shall ignore the aspect of selecting the right titles for the chapter/section.) You can write your chapter titles and compile your document. To get an overview of the flow of the argument/text in the document you view the table of contents.

If you're happy with the order of presentation, then you're done but this hardly ever happens the first time, so you have to reorder the chapters/sections, add new chapters/sections, or remove them.

I use vim and three keystrokes let me remove the current \include<chapter> line. A single keystroke lets me put it at another target position. This lets me quickly rearrange the order of the chapters and I do this until I think the order is right.

Notice that an undo-redo facility is also great because it lets you quickly undo the last changes, recompile your document (twice), see what it looked like before, redo the changes, compile your document (twice), and see what it looks like after the changes. Some editors have multiple undo-redo threads (but I've never used them).

BTW notice that this process doesn't require any mouse. All you do is put your document viewer on top of your editor. After that, a simple Alt+Tab lets you switch from the viewer to the editor or back---and all that with maximally-sized windows.

When I'm happy with the order of the chapters, I tackle the chapters, one by one. When tackling a chapter, I write the sections within that chapter in a similar way.

Notice that the technique also works if the chapter and/or section files contain text. A simple moving of a single line, lets you put put the chapter/section where it belongs. Without the files, this may not be so easy, unless you use a folding editor of course.

share|improve this answer
5  
AUCTeX also has support for folding. –  N.N. Jan 21 '12 at 14:18

Two editor-related tricks:

  1. (mac-specific) TexShop's Macro Editor allows you to insert a snippet of code by a hotkey. However, it limits you to command+key:

    enter image description here

    You can choose your own by going into Apple Menu>System Preferences>Shortcuts>App Shortcuts, press the + button. Enter the name of the macro and desired hotkey. This also works for assigning/reassigning other menu options in any app:

    enter image description here

  2. Sublime Text and Emacs has a feature called multiple cursors that lets you type in multiple parts of a document at the same time. Watch as I cleverly readjust the &s in a tabular:

    enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.