Showing posts with label LaTeX. Show all posts
Showing posts with label LaTeX. Show all posts

Monday, March 24, 2008

LaTeX Appendectomies

I have need of a LaTeX package. I think a lot of people would find this package useful. I would prefer not to write it myself.

This package would take a mode argument in the preamble and format the document in one of three ways: as a conference submission, as a camera-ready conference paper, or as a tech report.

Suppose I have a theorem and that theorem has a proof.


  • In a conference submission, the theorem would appear in the main text and would be re-stated along with its proof in an appendix.

  • In a camera-ready conference paper, the theorem would appear in the main text and the proof would not appear at all.

  • In a tech report, the theorem and the proof would appear inline in the main text.


Preferably, proofs could be included in the main text or sent to an appendix on a case-by-case basis. Proofs could also have "sketch" versions and full versions: the sketch version appears in the main text of a conference paper (either kind) and the full version appears only in a tech report.

Suppose that, in proving a theorem, I first prove a lemma.

  • If the proof of the theorem appears in the main text (or an appendix), then the lemma and its proof should also appear in the main text (or the appendix), before the theorem.

  • If the proof of the theorem is omitted, or if a proof sketch is included which makes no reference to the lemma, then the lemma and its proof should not appear at all.



One should be able to conditionally include text depending on the mode. For example, in camera-ready conference mode, one would probably include the sentence: "Full proofs of all theorems appear in a technical report [citation here]."

The only package I've found that does anything like this is thrmappendix , but it doesn't allow for a proof to appear in the main text at all. It's primarily concerned with the appearance and re-appearance of the theorem, with or without its proof; I'm primarily concerned with the appearance or suppression of the proof.

Sunday, November 25, 2007

Style Guidelines for People

In the midst of some unrelated Googling, I came across Luca de Alfaro's style guidelines for student co-authors. This is good stuff. I particularly like "one sentence per line" b/w "fill-sentence macro". It's an elegant solution to a frequently annoying deficiency of diff, which is unfortunately the baseline for anyone collaborating via CVS or SVN. I tweaked his macro to get nice indentation in AucTeX:


(defun fill-sentence ()
(interactive)
(save-excursion
(forward-char)
(forward-sentence -1)
(indent-relative)
(let ((beg (point)))
(forward-sentence)
(if (equal "LaTeX" (substring mode-name (string-match "LaTeX" mode-name)))
(LaTeX-fill-region-as-paragraph beg (point))
(fill-region-as-paragraph beg (point))))))
(global-set-key "\ej" 'fill-sentence)


[UPDATE 1/20/07] Fixed an off-by-one error when the cursor is on the first character of the sentence by adding (forward-char).

LaTeX Letters

I was trying to write a letter in LaTeX the other day:


\documentclass{letter}

\address{Nowheresville}

\signature{Me}

\begin{document}
\begin{letter}

\opening{To Whom It May Concern:}

Hello, there.

\closing{Sincerely,}

\end{letter}
\end{document}

This led to the following two errors, which shed little light on the situation:

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...

l.10 \opening{To Whom It May Concern:}

and (on a different example)

! Incomplete \iffalse; all text was ignored after line 66.

\fi
l.16 \end{letter}

Runaway text?
\@mlabel{}{\unhbox \voidb@x \ignorespaces \global \let

The problem, as it was gently explained to me, is I had omitted the second mandatory argument of \begin{letter}, which is the address of the recipient. The following is correct:

\documentclass{letter}

\address{Nowheresville}

\signature{Me}

\begin{document}
\begin{letter}{Foo Corp.}

\opening{To Whom It May Concern:}

Hello, there.

\closing{Sincerely,}

\end{letter}
\end{document}


[UPDATE] I just realized that the reason I got so confused about this is that I was working off a previous business letter that was formatted like:

\begin{document}
\begin{letter}
{
Foo Corp. \\
... \\
ATTN: Warranty Dept.}
...

I'm not sure if I intended it to be the case (probably not), but LaTeX picked up the braces around the address as the argument to letter. When I used this as the template for a personal letter and deleted the address, all hell broke loose.

Sunday, March 18, 2007

Buffer-local Dictionaries

If you write technical documents—especially technical computer science documents with code snippets and the like—you're likely to come across a spell-checking dilemma like the following:

Unrecognized word: pBuffer

Replace with: (0) buffer (1) puffer (2) puffier (3) pouffe ...
Space: Accept word this time
a: Accept word this session
i: Insert into personal dictionary

"pBuffer" is not a real word that should go in your personal dictionary, so you accept the word for this session. Say you're going to write 5,000 more drafts of this document. All of those weird little technical words could get pretty annoying after a while.

In Emacs, you can type 'A' instead of 'a' to insert the word in a "buffer-local dictionary." You can also presumably add a Local Words comment somewhere in your file by hand, like

% Local Words: pBuffer

Why is it always so hard to figure this stuff out?

Hat tip to the Linux Documentation Project.

Bonus tip: You want an em dash in your blog post? Try —. You would think I couldn't be so em dash-happy and not know this already, but I am and I didn't.

Saturday, March 17, 2007

\tag{eqname}

So you want to give an equation a name in LaTeX, instead of the number it gets automatically... For some reason, Google will resist telling you how. You may be tempted to use the eqname package. No need! No need at all! Use the \tag command. Why isn't this easier to figure out?

UPDATE: I apologize to the writers of the amsmath documentation, who mention this pretty much immediately after they introduce the concept of equation numbering. I always assume that Google can find these things for me.

Friday, March 16, 2007

Lazy Scholarship

Fill in the blanks: You are ___% more likely to get cited if you include BibTeX and/or EndNote entries for your publications on your web page. You are ___% less likely to get cited if the PDF of your paper doesn't support cut-and-paste.

Tuesday, February 20, 2007

Comments in BibTeX

Be warned: there is a @Comment directive in BibTeX, but it doesn't appear to do anything.

UPDATE: @Comment works as expected so long as you use it outside any other directive. E.g., the following will not work,

@InProceedings{ key,
title = {\BibTeX comments considered harmful},
author = {Christopher L. Conway},
booktitle = {Procrastiblog Symposium on \LaTeX Arcana},
year = 2007,
@Comment{ This never actually happened. }
}
whereas the following is fine,
@InProceedings{ key,
title = {\BibTeX comments considered harmful},
author = {Christopher L. Conway},
booktitle = {Procrastiblog Symposium on \LaTeX Arcana},
year = 2007,
}

@Comment{ The above never actually happened. }