Wow, I took some time to get my other work done but I didn't expect to be away this long. Apologies to my avid followers for the absence. The two of you know who you are.
The last few months have been a lot of fun with LaTeX as I have worked to streamline my day-to-day workflow around the lab. One of the things I do rather consistently is calibrating cameras for atmospheric remote sensing. This is mind-numbing, boring, repetitive work: perfect for a computer. I generally do things like this once, maybe twice, by hand and then script the whole thing so that I never have to do anything other than hit 'enter' again. The last step in this pipeline is having scripts that produce nice LaTeX summaries of a calibration run. I love this stuff. I'll write about the whole setup and fun tools like gnumeric (spreadsheet with LaTeX table output) and xfig (drawing tool with LaTeX output) at a later date.
For now, I'll get back on track with an issue that came up just this afternoon. I had the opportunity to get out of the lab and attend a LaTeX workshop/class put on by a local Linux User Group. A question came up during the discussion about resetting equation numbers in LaTeX. If you haven't experienced it yet, LaTeX does a number of things somewhat automatically for you like number equations, pages and figures. This is accomplished through a series of internal counters which keep a sequential, running tally. So, the questioner was wondering, how can one reset this numbering say, for a new section or chapter?
There are a few ways of doing this (probably several more, but these are very accessible) depending on what you want. If you want the numbering to reset at the start of each section or subsection but reflect the section or subsection (first equation of section is numbered 1.1, next is 1.2, first equation of second section is 2.1, etc), put the following two lines into the preamble of the document:
\usepackage{amsmath}
\numberwithin{equation}{section} or {subsection}
We've yet to talk about it here but the preamble of a LaTeX document is anything you put between the \documentclass{} and \begin{document} commands.
I've put together a couple of example files to show how this can be done:Number reset within section and Number reset within subsection
If you want more general control over equation numbers (or any counter), use setcounter and use it thusly:
\setcounter{equation}{number you want to start with - 1}
place this line before the location where you want the new numbering to start and after the last place you want the old numbering to remain and you reset the counter. In the default LaTeX setup, this will give you an integer running tally which jumps out of sequence. I have an example of this here
So, now you too can reset your equation numbers and drive your readers crazy. Enjoy!
Wednesday, October 26, 2011
Friday, February 4, 2011
Dominant paradigms
LaTeX does two main things for me. It produces fantastically typeset and beautiful documents but, perhaps more importantly, it helps me write a consistent, logical structure into my documents from the start. I'm not a natural writer and I can get REALLY lost in my own thought processes. Trying to sit down at the keyboard and just write a document will result in logical and grammatical diarrhea which will take awhile to sort out, reorganize and turn into something useful.
The tools and techniques I use are available in WYSIWYG document software but you'll find them discussed in the last chapter of the manual with a title something like "Things less than 1% of you might use (but only if you are in professional publishing)". They are available but, they're far from the dominant paradigm. If they try to use it at all, most people end up jury-rigging this kind of functionality instead of using what the software offers and then end up with a nightmare. LaTeX gives you simple hooks to build your document off of and they're one of the first things you learn about.
When I write something I pretty much always follow these steps (and this goes equally for papers, articles, posters and Beamer presentations.):
It's all about process. A good, consistent process will do wonders and LaTeX makes it easy to build a good process.
The tools and techniques I use are available in WYSIWYG document software but you'll find them discussed in the last chapter of the manual with a title something like "Things less than 1% of you might use (but only if you are in professional publishing)". They are available but, they're far from the dominant paradigm. If they try to use it at all, most people end up jury-rigging this kind of functionality instead of using what the software offers and then end up with a nightmare. LaTeX gives you simple hooks to build your document off of and they're one of the first things you learn about.
When I write something I pretty much always follow these steps (and this goes equally for papers, articles, posters and Beamer presentations.):
- Document setup: write preamble text, \usepackage for packages I know will be necessary (math, graphics, etc), and \begin{document} \end{document}
- Now lay out the high level logical structure by putting in \section{} tags. This might be as simple as
\section{Introduction}
I'll often also include commands or comments to note where titlepage, table of content, bibliography, etc. commands will go.
\section{Background}
\section{.....}
\section{Conclusions} - Now lay out more refined levels of logical structure with \subsection{} and \subsubsection{} (Leslie Lamport wrote LaTeX to only go to subsubsection level for good layout reasons. You can define lower levels but it's often not worth it. When I need another level I use \subsubsection*{} to get an unnumbered subsubsection). This gets you to a a deeper structure like
\section{Cloud Droplet Retrieval}
%Break down relevant instruments that do retrievals
\subsection{MODIS}
\subsubsection{Technique}
%Radiance retrieval a la Nakajima-King
\subsubsection{Assumptions}
\subsection{POLDER}
\subsubsection{Technique}
%Fits to Mie simulation
...etc - Note that in building this structure I haven't written any of the document. I'll include notes about the final level of structure but I try to avoid actually writing any of it. The notes can be done as in-line comments like above, as live text or within a comment environment. Each method can have its place.
I don't write much here because I find that once I have something written as a sentence or as paragraphs, I become very reluctant to alter it significantly. Maybe I'm too attached to supposed cleverness but, I tend to move sentences around and then morph grammar rather than do the right thing; delete them and move on. Better to not have them there in the first place. - Once this logical structure has settled (or is mostly settled), I start to flesh out the body of the text. You can do this by simply expanding on the comments you've left behind but often I will do this by writing each section in a separate document and using \input{} lines to bring them into the main document. This keeps the logical structure of the document clean, easy to read and easy to edit around my actual text. Doing it this way can lead to headaches when you try to do labels and references for figures, tables, though, so experiment and see what works best for you. LaTeX can handle the separate files well but it can be a pain to the carbon wetware moving around in multiple files trying figure out what goes where.
- Clean up anything in the actual typesetting that LaTeX doesn't do quite the way you want (LaTeX is built to be smart about typesetting but sometimes I feel a need to do things my way)
It's all about process. A good, consistent process will do wonders and LaTeX makes it easy to build a good process.
Wednesday, February 2, 2011
Introductory tip
Well, this sort of started as a joke but, here I am starting with my first LaTeX tip of the day. Names notwithstanding, I don't intend to hold myself to a guaranteed tip per day. I do have a few other things to do but, as time permits, I will put down in text any little hints that I have for producing documents using LaTeX. I've used LaTeX for a long time (and TeX and nroff/troff before that) and used them all long before ever seeing Word or OpenOffice so to me it's not really a question of superiority of one over the other. I do happen to think LaTeX is superior in all ways but what's most important is that LaTeX has helped me to develop a process for document preparation that focuses on the document logic and structure first instead of trying to shoehorn it in later. Sure you can do this with any system but, I think LaTeX and UNIX just make it easier and more natural.
Today's tip is simple just to get things started. If you haven't been there already, I suggest you check out two places online: CTAN and wikibooks.
CTAN is the Comprehensive TeX Archive Network. All things TeX and LaTeX can be found there. All packages, documentation related software, etc. usually end up here.
Wikibooks LaTeX is a great resource and reference for learning how to use LaTeX. I used to store and print out all the package manual pdfs (still have them in my file cabinet) for reference but lately I head to wikibooks first and see if that provides a solution to my problem. if I need to go deeper, I start reading up on the appropriate package.
Today's tip is simple just to get things started. If you haven't been there already, I suggest you check out two places online: CTAN and wikibooks.
CTAN is the Comprehensive TeX Archive Network. All things TeX and LaTeX can be found there. All packages, documentation related software, etc. usually end up here.
Wikibooks LaTeX is a great resource and reference for learning how to use LaTeX. I used to store and print out all the package manual pdfs (still have them in my file cabinet) for reference but lately I head to wikibooks first and see if that provides a solution to my problem. if I need to go deeper, I start reading up on the appropriate package.
Subscribe to:
Comments (Atom)