views:

1159

answers:

2

When I include \overline{x} or other special characters in the caption text of a table, the whole caption text won't appear at all. When I put simple text without special characters, the caption works fine. How can I include special characters in the caption?

+3  A: 

Are you putting $ around the maths? I.e.:

\caption{This is a caption with maths $\overline{x}$ in it.}
Adam Jaskiewicz
If you're not putting the $ in none of the text will show up :)
Noah
Yes, that was the mistake. Thank You!
Zequj
You're welcome. Please consider marking this answer as "accepted" so that other users can see that your question is answered.
Adam Jaskiewicz
@Zequj: You should accept this answer
toxvaerd
Oh sorry, I'm a beginner with the site. Now it's accepted.
Zequj
+1  A: 

Apparently your real problem was that TeX's fancy error correction mechanism prevented you from knowing that there was a syntax error in the document. Back in 1982 or so, running TeX on a long document would take so much time that Knuth didn't want TeX to just quit when it ran into an error. Instead, TeX tries to guess what you meant and go on typesetting the document, so that you can fix a bunch of errors before you run it again; for example, when it spots a math-mode command outside math mode, it assumes that you forgot a dollar sign and inserts it. No automatic error-correction mechanism is perfect, so syntax errors often cause some part of text to be lost, or typeset in a wrong way.

TeX does try to tell you that it has found errors, but I suppose current IDEs make it easy to ignore the output. Try running latex on the document from the command line and pay attention to what it says. For example, the short document

\documentclass{article}
\begin{document}
It seems \sqrt{2} I forgot some dollar signs.
\end{document}

causes TeX to prompt you with

! Missing $ inserted.
<inserted text> 
                $
l.3 It seems \sqrt{
                   2} I forgot some dollar signs.
?

The 2009 way of dealing with this is to type X to quit, fix the source document, and run latex again - but you can actually enter other commands at the prompt to edit the input that TeX sees. If you just type Q (to run quietly - same as specifying \batchmode, which Emacs or whatever IDE you are using probably does for you) you get a typeset document as a result, and it might not be obvious that there are in fact syntax errors in it.

Jouni K. Seppänen
Yes, as this was my first time with LaTeX, I actually got a few errors and warnings from my LaTeX code but the output was ok until the problem with the maths formulae, so I ignored them. Now I understand what it's about. Thank you!
Zequj