Package caption error caption outside float

When I add the following table (table1 shown below) I don't get any error, but when adding table2 (shown below) I get the error i)caption outside float. caption ii) Undefined control sequence

When I add the following table (table1 shown below) I don’t get any error, but when adding table2 (shown below) I get the error i)caption outside float. caption ii) Undefined control sequence caption. What is the difference between these two table definitions? These two seems same to me.

latex code for table1 :

begin{table}[h]
begin{center}
begin{tabular}{| p{2.5cm}| p{2.5cm} | p{2.5cm} |}
hline
textbf{AAA} & textbf{BBB} & textbf{CCC} \
hline
DDD   & 111 & 333\ hline
EEE   & 222 & 444\ hline
end{tabular}
end{center}

caption{Caption1}
label{table1}

end{table}

……………………………………………………….

latex code for table2:

begin{table}[h]
begin{center}
begin{tabular}{| p{2.5cm}| p{2.5cm} |}
hline
textbf{GGG} & textbf{HHH} \
hline
III                    &              113\ hline
JJJ                    &              234\ hline
KKK                    &              345\ hline
end{tabular}
end{center}
caption{Caption2}
label{table2}
end{table}

David Carlisle's user avatar

asked Oct 28, 2011 at 10:26

RIchard Williams's user avatar

RIchard WilliamsRIchard Williams

1,1793 gold badges12 silver badges17 bronze badges

2

The second table started with

begin{table}[h]

instead of

begin{table}[h]

meaning it missed a and that was what gave the error of a caption outside a float.

answered Oct 28, 2011 at 10:48

N.N.'s user avatar

Check carefully your document when such errors pop out; before the editing to the question, the second begin{table} wasn’t preceded by the backslash. In this case LaTeX is happy to print «begintable[h]» and then start the center environment.

If you had proceded on by hitting return at the error message you’d have seen another one telling you that the document environment had been closed by table.

By the way, don’t use the center environment in this situation:

begin{table}
centering
<table data>
caption{The caption}label{thelabel}
end{table}

answered Oct 28, 2011 at 10:47

egreg's user avatar

egregegreg

1.0m127 gold badges2539 silver badges4092 bronze badges

2

Содержание

  1. LaTeX.org
  2. LaTeX.org on Twitter — follow us
  3. LaTeX forum ⇒ Document Classes ⇒ caption package and
  4. caption package and
  5. caption package and
  6. Re: caption package and
  7. caption package and
  8. Re: caption package and
  9. caption package and
  10. Errors while processing latex files
  11. Contents
  12. General notes on errors
  13. General tricks to try
  14. List of error descriptions

LaTeX.org

We love good questions

LaTeX.org on Twitter — follow us

LaTeX forum ⇒ Document Classes ⇒ caption package and

caption package and

Post by christina_t » Tue Sep 16, 2008 1:29 am

I am having problems with the caption package. I downloaded the new version and it seems that now my captions do not work right. This is part of the preamble

and what I am trying to do is to put a different caption in the table of figures by using :

However what I get in the dvi is that both [] <> are included in the caption, the numbering of the figure goes crazy and the log says:

! Package caption Error: caption outside float.

Any advice would be greatly appreciated

Recommended reading 2021:

caption package and

Post by gmedina » Tue Sep 16, 2008 1:44 am

can you please post some of the actual code you are using for one of your tables or figures (in the sense of a minimal working example)? It seems that you are using caption outside a floating environment (as suggested by the error you are getting); if this is so, then maybe you could try using captionof (provided by the caption package).

Re: caption package and

Post by christina_t » Tue Sep 16, 2008 1:59 am

hi!
thanks for the prompt reply

There are several figures with the same problem. one example:

caption package and

Post by gmedina » Tue Sep 16, 2008 2:07 am

just as I suspected. The caption command can only be used inside floats (i.e., inside figure and table environments). Since you are buiding your figures without the floating environment, you cannot use caption ; you can use captionof instead; take a look at the following example:

Edit : initially I forgot to delete some additional code I used to do my test.
Edit 2 : just for completeness’ sake I included the graphicx package in my code (thanks to Stefan_K ).

Re: caption package and

Post by christina_t » Tue Sep 16, 2008 2:19 am

Something really strange happenned

I did as you suggested and it was still not working, i had a black box above the figure and the same problem with the caption. however, once I deleted it (your suggested format) from the document, I did latex once and it just worked!! i do not understand this!

is there a problem if i use minipage instead of a figure environment? but how and why would it work now all of a sudden?? i did not change a thing!

caption package and

Post by gmedina » Tue Sep 16, 2008 2:23 am

my code works OK. Notice that since you are generating a list of figures (and possibly a list of tables) you must compile your document twice .

Edit : I just noticed that I put a rule command in my code to do some tests and I forgot to delete it; here’s how it should be:

I will correct the code that I posted above.

No, but your figures won’t float. In the following links you can find information about floats in LaTeX:
Moving tables and figures in LaTeX
Figure (or table) exactly where I want it

Edit 2 : just for completeness’ sake I included the graphicx package in my code (thanks to Stefan_K ).

Источник

Errors while processing latex files

This web page tries to give some help with error messages that may pop up while processing your latex file index.tex.

Now don’t get scared. I cannot remember ever seeing most of these errors and I have been using TeX and LaTeX for all my documents a quarter century or so. (Then again, my memory definitely does not extend over a quarter century. More like a quarter hour nowadays.) And almost all the complicated errors are self-inflicted. Or professor-inflicted. If you do not make your own problems, the problems will probably be typos and forgotten <, >, or $ characters. Or often you forget a before a special character that needs one. (At least, I do this often.)

However, if your admirable professor tells you that he or she would like the page numbers in Egyptian hieroglyphs in the middle of the page, go for it! Ask your beloved professor to help you get this just perfectly right. Don’t leave the professorrq<>s office until it is done. (Visit early in the morning, of course.)

Other than that very important observation, this web page needs work. However, some of it may already be useful. On first use, be sure to read the first two entries of the contents below (excluding this preface).

If you have any errors that would be good to include here, please e-mail them to me. You will be helping other LaTeX users, even those that do not use l2h. If you can paste them directly from the log file, (so that the log file reader can recognize them), it would be even better. And so it would if you can also give a solution to the problem.

Contents

General notes on errors

When your latex file, index.tex, is processed, errors may be found. On a serious error, processing stops. An error message will be printed, preceded by a !. The line number in your latex file at which the error is discovered is printed before the message, following an l.

To be sure, the error might not be in your own index.tex file. It may be in a package you load. Then the filename of that package will have been printed earlier following a «(«, one that is not yet closed by a «)». Now packages by themselves do not have errors. I hope. But when you load several different packages, and you will, they might conflict. Then there is not much you can do except try to change the order in which the packages are loaded. If that does not help, you will need to live without one of the packages. Fortunately, such problems are rare, and mostly restricted to recently developed packages. So the discussion here assumes that the error is in your index.tex file.

The first thing to do is to read the error message. Then read the line number at which it was found. Look in your tex file at and maybe before that line number and try to find an error. (See the next entry for some general rules in doing so.)

After you have found the error, you can correct it in your tex file. But do not save. Processing can get really weird if the file changes while it is still being processed. Also, if you make changes, note that this may change the line numbers. The processing will still print the line numbers of the original file.

After hopefully identifying and correcting each error, hit Enter in the processing window. Note that one error often causes more than one error message. The additional error messages should disappear too the next time you process the file.

If there are countless error messages, the best thing may be to enter a «q» or «x» at the ? prompt. Then after having saved your corrections so far, reprocess. Hopefully there will not be that many problems anymore.

Also, processing can get very nasty if latex tries to open some file and cannot find it. If you get stuck, try hitting «c» or «d» while holding down Ctrl. Or try to specify a junk file name like «/dev/null» or «nul».

General tricks to try

There are some general tricks to identify errors.

Use the «a» key to get a list of all errors. Maybe another error message can clarify the problem.

Remember the special characters. To get an actual %, you need %. (That is a mistake even experienced latex users still make regularly.) For an & you need &, for a # you need #, for a you need backslash, (\ is new line), for a printed < you need <, and for >you need >. However, [ and ] are normal, while [ and ] surround math.

Except in mathematics, the characters ^ and _ are illegal too, and will not do what you think they should. A * or [ immediately behind \ will cause problems. The trick is then to enclose that following stuff between < and >.

Look carefully for typos. A 1 may resemble an l, a ) a >, etcetera. Carefully identify for each < the corresponding >that closes it. Check that begin is closed by end, not end.

Try to find the error message on this web page and see whether that gives a useful hint. (But there are almost infinitely many possible problems for a single error message; this page cannot list them all. Using you intuition is often the best guide to what is wrong.)

Try to temporarily remove the apparently problematic command or environment. Does the problem disappear? If so, you know where the problem is.

But it is not uncommon for even experienced latex users to get stumped by an error. In that case, a divide and conquer approach may be your best bet.

Try enclosing the general problem area between begin and end lines. The enclosed area will no longer be processed. So if your error is indeed in the selected area, the processing error should disappear. (If it does not disappear, select a bigger area).

After you have identified the problem area, move roughly half of it outside the comment block. (Of course, select complete units. Do not break groupings, or you create additional errors.) If the error reappears, it is in that half. If not, it is in the other half. Either way, you have narrowed down the problem area by a factor 2.

Move everything out of the comment block. Then put about half of the now identified smaller problem area back inside. If the error is in that half, it will not show up. In the other half it will. That allows you to narrow the problem area even more closely. And so on until the problem area is so small that there is only one possible cause to the error left.

Of course, then you will notice that the problem was trivial, and you should have seen it in a second. No need for all this chopping into pieces. When you know the answer, the problem is always simple.

List of error descriptions

Latex did not see an end line. It is patiently waiting for whatever other exciting stuff you have planned for it.

  1. Check that you have a correctly spelled end.
  2. Check that end is not hidden behind something like an endinput line.
  3. Check that you are indeed processing the index.tex file that you think you are processing. (Create an error right at the start of the file if you have to.)
  4. If stumped, try the general tricks.

No error message. But bad links in the pdf side bar.

Sometimes the pdf has bad links in the sidebar even though no rerun is requested in the log file.

  1. Run latex once more. L2h will complain, but just hit «c» to continue. Then run «p» as needed. That fixed it for me.
  2. Sometimes the link of an addcontentline command goes to the end of the previous chapter instead of the start of the new chapter (which is an unnumbered chapter* <. >chapter). In that case, make sure the thing is formatted as follows: The additional first two commands will hopefully fix things.

==> Fatal error occurred, the output PDF file is not finished!

This just tells you the pdf was not made.

This just tells you the pdf was not made.

  1. Look for the earlier error message that gives the reason.
  2. If stumped, try the general tricks.

(end occurred inside a group at level nnn)

Something was not properly closed when the end of the file was reached.

  1. Look for a < bracket that has never been closed by a >.
  2. Look for other things that may not have been closed, like environments, math, etc.
  3. If a pdf was created, or can be created, look at the end of the document in the pdf for clues. If, say, an <it was not closed, things will be in italics.
  4. If stumped, try the general tricks.

(end occurred when if. on line nnn was incomplete)

Unless you write your own latex code, you did not close something or put something in a place latex cannot accommodate it.

  1. Look for missing > brackets.
  2. Look for other things that may not have been closed, like environments, math, etc.
  3. If stumped, try the general tricks.

(Fatal format file error; I’m stymied)

From the TeX FAQ:

The commonest cause of the message, is that a new binary has been installed in the system: no two TeX binaries on the same machine can understand each other’s formats. So the new version of TeX you have just installed, won’t understand the format generated by the one you installed last year.

Resolve the problem by regenerating the format; of course, this depends on which system you are using.

  • On a teTeX-based system, run or to build only the format that you are interested in.
  • On a MiKTeX system, click Start-> Programs-> MiKTeX version-> MiKTeX Options, and in the options window, click Update now.

I first tried the fmtutil command as root [administrator] again and it still didn’t work. Then I ran the command as normal user and now everything works.

TeX has nothing to do and asks you what it should do. You will get this error, for example, if you run latex interactively on an empty latex source file. Since in the l2h shell you do not run latex interactively, you should not get this error there. (Just an «emergency stop» one.)

  1. Say `end’? (Actually, I got an «TeX capacity exceeded, sorry» error on that. But it did end the program.)

! A was supposed to be here

In LaTeX, boxes are created by newsavebox, given content by savebox, and used by usebox. Plain TeX uses newbox, setbox, copy, etcetera.

  1. Check that your savebox or usebox has a box in its first argument.
  2. If stumped, try the general tricks.

! Ambiguous; you need another

Compare the items on double subscripts and superscripts.

  1. Did you use a fragile command, like footnote or parbox, in a place it should not be? Like in a caption? If you really need it there, try putting protect right in front of it.
  2. A misused frac command, like frac <1,2>can cause this.
  3. Apparently, some commands inside fragile commands can cause this. Try temporarily removing the content and see whether the error disappears.
  4. If stumped, try the general tricks.

! Arithmetic overflow

Something went wrong deep inside the processing program.

The character code of a normal character was specified outside the valid range from 0 to 127.

A numeric delimiter code must be between 0 and 2^<24>-1, (delcode) or 2^<27>-1 including the class number (delimiter).

A numeric math code was specified outside the valid range from 0 to 32767.

A math character with a code outside the valid range from 0 to 32767 was encountered.

An error in the pstricks package. A node name must only contain letters and digits and start with a number.

Latex expected a number, but did not get a valid one.

  1. Careful examination of the correct form of the command listed will usually show up the problem.
  2. If stumped, try the general tricks.

! Bad register code

One counter that is fairly likely to run out is the footnote one. There are only so many footnote marks, after all. (9 symbolic ones, to be precise.)

  1. Too many footnotes?
  2. Too many thanks commands?
  3. Converting a counter > 26 to a letter a-z can also cause this error.
  4. If stumped, try the general tricks.

! Dimension too large

I think this means a length is specified that is larger than possible.

A discretionary line break has 3 parameters: text before the line break, text after the line break, and text if there is no line break in the first place.

  1. Check that it hhas three <. >parameters of reasonable size.
  2. If stumped, try the general tricks.

! Display math should end with $$.

Actually, in latex you should use [ and ] instead of $$ and $$. Or better, use begin and end.

  1. Change to one of the correct forms. Then you know what begins math and what ends it.
  2. Math may not contain blank lines. If you leave a single blank line in an equation, it will generate the error message ! Missing $ inserted, followed by ! Display math should end with $$. followed by ! LaTeX Error: Bad math environment delimiter. Remove the blank line and all three error messages should disappear.
  3. Now latex2html has a nasty habit of leaving blank lines when it removes the labels from equations. These errors will then show up in its math images processing. In particular, they will show up in images.log. To fix this, put the label <. >in equations at the end, followed by a %. Furthermore, leave some mathematics on the same line, before the label<. >%.
  4. Use of $$ inside equation mode can cause this, I hear.
  5. If stumped, try the general tricks.

! Double subscript

If you think about it, _c is not the same as a_. In the first case, c is a subscript to the complete expression a_b. In the second case, it is a subscript to the subscript b only. So in the second case, c should be a lot smaller than b. In the first case, it must be at least as big as b. TeX needs to know which case it is.

If you think about it, ^c is not the same as a^. In the first case, c is a superscript to the complete expression a^b. In the second case, it is a superscript to the superscript b only. So in the second case, c should be a lot smaller than b. In the first case, it must be at least as big as b. TeX needs to know which case it is.

  1. Add the brackets already.
  2. Note that in math, ‘ is a superscript too. (It is really the same as ^prime.)
  3. If stumped, try the general tricks.

! Duplicate pattern

I assume this refers to hyphenation patterns. In that case, you should never see it unless you are an expert.

Tex got in trouble. The actual error may be much earlier.

  1. You will see this error when LaTeX cannot find a file in an input or include type statement.
  2. You will see this error when LaTeX cannot find the end line. Check its presence and spelling.
  3. If stumped, try the general tricks.

! Extra right

A right, which must precede some bracket or a point, must match an earlier left.

You put in too many & characters in a single row in your table or array or matrix. Each & should separate two columns. (Note that what TeX calls cr is what LaTeX calls \. TeX has started a new row to fix things up.)

  1. Is the & count right?
  2. Did you mean &amp somewhere?
  3. Did you forget or mistype \ at the end of the previous row?
  4. Did you use an invalid range in a cline?
  5. Too large a count in a multicolumn?
  6. Is there something wrong in the column specifications? Check p and @ commands for correctness.
  7. If stumped, try the general tricks.

! Extra .

There is something not matching something else, like maybe a fi, or, or else not matching an earlier if. Unless you write your own TeX code, that would probably mean that something has been put in the wrong place.

There is some problem with figuring out what begins or ends what.

  1. Unlike what it says, check not only that there is a < for each >, and a $ for each $, but also a [ for each ] and a ( for each ). And that they are properly nested: <small $a>=b$ is wrong. You must close the math before closing the < with >.
  2. If stumped, try the general tricks.

! File ended while scanning use of end.

You did not close something properly. May be just a forgotten >. LaTeX has now reached end of file without finding the closing bracket.

You did not close something properly. May be just a forgotten > or end<. >.

A needed font seems to be corrupt.

  1. Error in the font specification?
  2. Try to reinstall the font?
  3. Try to use a different font?

! Font . at . not loadable: Metric (TFM) file not found.

A needed font is not found.

  1. Error in the font specification?
  2. Try to install the font?
  3. Try to use a different font?
  4. You get this error if you try to use plain latex to process a template set up for xelatex. Check the value of pdfengine or webengine.

! Font . not loadable: Metric (TFM) file not found.

A needed font is not found.

  1. Error in the font specification?
  2. Try to install the font?
  3. Try to use a different font?
  4. Are you using plain latex where xelatex is needed? Check the value of pdfengine or webengine.

! Font . not loadable: Metric (TFM) file or installed font not found.

A needed font is not found.

  1. Error in the font specification?
  2. Try to install the font?
  3. Try to use a different font?
  4. Are you using plain latex where xelatex is needed? Check the value of pdfengine or webengine.

! Font . not loaded; Not enough room left

I do not think that should happen with an up-to-date version of LaTeX.

  1. Do you really need all these fonts?
  2. There are ways to process a document in parts. That is described in Lamport’s LaTeX User’s guide & Reference Manual.

! fontspec error: «font-not-found»

The fontspec package cannot find the specified font.

  1. Did you mistype the font name?
  2. Does the font exist? Use the «Character Map» program to check. If it does not, maybe you can install it.

! Forbidden control sequence found

  1. Try removing it?
  2. If stumped, try the general tricks.

! Huge page cannot be shipped out

Never seen this one in my life. Doubt that it would happen with a modern latex version. Unless there is something really, really, wrong.

When interactive, typing in the correct file name, or correct package name, is the best way to proceed. However, latex in the l2h menu is not interactive and all processing aborts.

  1. Interactively, LaTeX will be happy as long as it gets any valid file name.
  2. Interactively, the way to get LaTeX to stop asking depends on your operating system and TeX version. Try entering x a couple of times. Or nul or /dev/null. Or try hitting c while holding down Ctrl.
  3. Interactive or not, you either have to provide a valid link to an existing, readable file, or remove the command trying to read it.
  4. If stumped, try the general tricks.

! I can’t go on meeting you like this

Because LaTeX loves you, it feels really bad about all the problems resulting from your error.

  1. Fix the problems you have figured out so far and try processing the latex again.
  2. If stumped, try the general tricks.

! I can’t write on file `. ‘

Latex wants to create a file, but it cannot do so.

  1. You may get this error if you have an old version of index.pdf open in Adobe Acrobat and postcript or pdflatex is trying to create a new one. You will need to exit Acrobat and then try the «l» or «p» key again.
  2. No more disk space?
  3. Are you in a location where you have no privileges to write the file?
  4. Does someone else, like system, own the file that is to be replaced?
  5. If stumped, try the general tricks.

! Illegal magnification has been changed to 1000 (. ).

You are not supposed to use magnification in latex.

  1. Check that «scaled» font scalings use valid numbers.
  2. If stumped, try the general tricks.

! Illegal math

TeX is being helpful here. You can do thousands of things wrong in TeX, and TeX actually reduced the possible problems for you to look for by a factor 2 or so!

There is a problem with a # parameter while defining something.

  1. If you mistype newcommand<mycommand>[2] <. >as newcommand<mycommand>[1]<. >, references #2 to argument 2 will be invalid.
  2. To get an actual #, use #.
  3. For a [re]newenvironment[n], the n parameters cannot be used in end stuff.
  4. There may be some #1, #2, . mistyped in a [re]newcommand or [re]newenvironment. (Or in a plain tex def statement).
  5. Check that you are not defining something inside defining something. (Like a newcommand inside a renewenvironment, say.)
  6. If stumped, try the general tricks.

! Illegal unit of measure (pt inserted)

Note that you cannot abbreviate 0in (0 inch), or 0pt (0 points, i.e. 0/72 inch) as 0. You still need to add «in» or «pt» even if the length is zero. (Which one of the two obviously does not make a difference.)

  1. Like above.
  2. This one is likely to follow an «Missing number, treated as zero» error. The missing number is really a missing length.
  3. Check the proper format of the command you are using.
  4. If stumped, try the general tricks.

! Improper hyphenation will be flushed.

Improper parameter to hyphenation

  1. Words should be letters and hyphens and separated by spaces.
  2. If stumped, try the general tricks.

! Improper `at’ size (

Unless you write your own LaTeX code, this is propably caused by something in the wrong place.

You put something invalid behind line or vector inside a picture environment

Are your < and >braces matched? Is [ or ( closed by ] or )? Are you entering math mode while already in it?

  1. Check properly opening and closing of math environments.
  2. Math may not contain blank lines. If you leave a single blank line in an equation, it will generate the error message ! Missing $ inserted, followed by ! Display math should end with $$. followed by ! LaTeX Error: Bad math environment delimiter. Remove the blank line and all three error messages should disappear.
  3. Now latex2html has a nasty habit of leaving blank lines when it removes the labels from equations. These errors will then show up in its math images processing. In particular, they will show up in images.log. To fix this, put the label <. >in equations at the end, followed by a %. Furthermore, leave some mathematics on the same line, before the label<. >%.
  4. A missing right after an array can cause this error.
  5. If stumped, try the general tricks.

! LaTeX Error: Bad use of \

A \ new line command is in an unallowed position.

Things like usepackage can only be used before the begin line. In particular, documentclass must be the first line, way before begin.

A caption must inside a «float» like a figure or a table.

  1. Is the begin of the caption environment properly spelled?
  2. If stumped, try the general tricks.

! LaTeX Error: Command . already defined

A new command being defined already exists.

  1. If you are defining a new command here, the name is already used for something else. Change it. Remember that LaTeX is case sensitive, so simply changing the case will fix things.
  2. Or to overwrite the old command, use renewcommand. Warning: this will get you into big trouble if the overwritten command is an important one.
  3. If this occurs during the loading of a package, the package conflicts with another one. (Not at all unusual.) Try changing the order of package loading, or forget about one of the two.
  4. If stumped, try the general tricks.

! LaTeX Error: Command circle invalid in math mode.

  1. Like it says? However, you can put a picture environment inside a mathematics environment. Then you can put the circle inside that picture. (As far as the surrounding math mode is concerned, the entire picture will be just some very big «letter».)
  2. If stumped, try the general tricks.

! LaTeX Error: Command end invalid in math mode

If you use math mode inside an itemize and forget the closing $, this will happen.

  1. Check properly closing of math mode.
  2. If stumped, try the general tricks.

! LaTeX Error: Counter too large.

  1. Unless you are defining a very long list, you probably brought this upon yourself somehow. (Who else is readily available to be blamed?)
  2. If you are really defining a long list, make sure it is a top level list, which is enumerated by arabic numbers. (Or learn how to define your own lists.)
  3. If stumped, try the general tricks.

! LaTeX Error: Environment . undefined.

An attempt to use an environment that has never been defined.

  1. Check for typos in the begin line.
  2. If it is part of a package, check the corresponding usepackage command.
  3. If stumped, try the general tricks.

! LaTeX Error: File `. ‘ not found

This error is serious because latex will terminate without finishing the document. The missing file may be a personal file that you are trying to input. Or it may be a package you are trying to load with usepackage that you do not have installed. If latex is trying to find a .sty, .cls, or .def file, it is a missing package.

  1. If latex is missing a personal file, put it in the same folder as index.tex. Then do not use a path in the input statement.
  2. If latex is missing a package, try finding the file on the web and put it inside the «texinputs» folder inside «l2h». Note that you may have to run latex on any .ins or .dtx file you find to get the sty file.
  3. If you are running latex though an editor like TeXstudio instead of through l2h, you may need to copy the files inside the «texinputs» folder inside «l2h» to the same folder as your document index.tex.
  4. If your latex is very old, the package might not work. Try to do without the package. Or upgrade latex to a more recent version. Rerun install_l2h after that.
  5. The missing file error is somewhat tricky when making web pages. While making web pages, latex might be looking for the file in the wrong folder. In general, make sure that you put your pictures in the same folder as index.tex. Not somewhere else. Or give latex a complete, (so-called absolute), path to the file. A «./», «../», or «subfolder/» path will not work.
  6. If stumped, try the general tricks.

! LaTeX Error: Float(s) lost.

Like it says; one or more figures, tables, etc., or marginpars have not been typeset. The actual error may be well before the point where the problem is recognized.

  1. You cannot put pictures or tables in minipages or parboxes. Or in footnotes, or anything like that.
  2. Putting something that has a floating location (figures, footnotes, . ) into something that also has a floating location causes this error. After all, where should LaTeX put, say, a footnote to a footnote? That does not make sense.
  3. Is a picture or table in the wrong place?
  4. If stumped, try the general tricks.

! LaTeX Error: Illegal character in array arg.

For «array» read «array» or «tabular» or «multicolumn» or whatever. The argument in which you define the format of the columns seems to be messed up. The normal letters are r, l, and c. Howver, there is also @<> and p<>.

  1. Read up on arrays, tables (tabular), or whatever on http://en.wikibooks.org/wiki/LaTeX/. Then check for typos in the array/, tabular/, multicolumn/, whatever, environment parameters.
  2. If stumped, try the general tricks.

! LaTeX Error: Lonely item—perhaps a missing list environment.

An item command was found. Latex cannot figure out what list it belongs to.

  1. Like it says? Cut and pasted something inside a list to outside it?
  2. Check the begin <. >statement of the list for typos.
  3. If stumped, try the general tricks.

! LaTeX Error: Missing begin

When this happens to me, I have put something printable before the begin line. Usually I misspelled some nonprintable command, turning it into printable text. But you could actually forget the begin line itself, I guess.

  1. Do not put any printable text before begin. Just packages, definitions, and such.
  2. Check everything before begin for typos or other errors.
  3. Apparently, misuse of marginsize can also cause this error.
  4. If stumped, try the general tricks.

! LaTeX Error: Missing p-arg in array arg

For «array» read «array» or «tabular» or «multicolumn» or whatever.

  1. While defining columns, there is a p not followed by argument.
  2. Read up on arrays, tables (tabular), or whatever on http://en.wikibooks.org/wiki/LaTeX/. Then check for typos in the array, tabular, multicolumn, whatever, environment parameters.
  3. If stumped, try the general tricks.

! LaTeX Error: Missing @-exp in array arg

For «array» read «array» or «tabular» or «multicolumn» or whatever.

  1. Read up on arrays, tables (tabular), or whatever on http://en.wikibooks.org/wiki/LaTeX/. Then check for typos in the array/, tabular/, multicolumn/, whatever, environment parameters.
  2. If stumped, try the general tricks.

! LaTeX Error: No such counter

A counter is undefined

  1. Do not use newcounter after begin.
  2. If you use a special style file, (like one provided by your target journal), some standard counter may have been disabled by the journal style.
  3. If stumped, try the general tricks.

! LaTeX Error: Not in outer par mode.

You put something, (figure, table, marginpar, . ), in the wrong place. They cannot be inside secondary environments.

  1. A figure or table inside a parbox or minipage will not work.
  2. If stumped, try the general tricks.

! LaTeX Error: Option clash for package .

Your guess is better than mine.

I think I have used the tabbing environment once, but I cannot remember when. Otherwise I use the tabular environment inside tables.

  1. Check that every pushtabs is closed by a corresponding poptabs. You cannot close one pushtabs by two poptabs.
  2. If stumped, try the general tricks.

! LaTeX Error: RequirePackage or LoadClass in Options Section.

Should not be there.

One thing that is obviously wrong is the supply of meaningful error messages.

  1. Like it says? Did you leave out the starting item in an enumerate or other list environment?
  2. Apparently, leaving the arguments away in a thebibliography environment can also trigger the above nugget of wisdom.
  3. If stumped, try the general tricks.

! LaTeX Error: Suggested extra height (. ) dangerously large.

Gee. You only live once. So live dangerously.

There are only so many tab stops possible. Don’t ask how many.

Rather than trying to create more blank space using \ \, use \[25pt]. Been there, done that. If there is no previous \, use vspace<12pt>.

  1. If you really need the \ try putting in a strut before it.
  2. If stumped, try the general tricks.

! LaTeX Error: This may be a LaTeX bug

Two balloonists got hopelessly lost over California. They lowered their balloon enough that they got within shouting distance of a tall building. That was the headquarters of the Digital Equipment Company. They shouted: «Hello! Hello! Where are we?» A mathematician on one of the top floors answered; «You are in a balloon,» he shouted back. That mathematician was Dr. Leslie Lamport, the author of LaTeX.

  1. Yes, this may be a LaTeX bug. Or a lady bug. But it is probably a consequence of an earlier error in your index.tex file.
  2. If stumped, try the general tricks.

! LaTeX Error: This NFSS system isn’t set up properly.

Well, set it up properly! Do I have to do everything here myself?

You cannot just keep putting list inside list inside list .

LaTeX has been hoarding your figures and tables for a rainy day. However, there is no more room in its small apartment.

  1. The first table or figure that is being hoarded may be a bottle neck. Change it placement options to [htbp] to make it easier to place. Reduce its size. Or use the H placement option of the float package to put it down whether latex likes it or not.
  2. A well placed clearpage may be an option.
  3. Did you really use that many marginpar commands? Shame on you!
  4. If stumped, try the general tricks.

! LaTeX Error: Two LoadClass commands.

That is definitely too much.

Too much. Too much. Try make do with only one. At the start of index.tex, preferably.

Latex is asked to tab to a column that is not defined.

  1. Did you miscounted the number of tabs, or forgot to start a new line?
  2. If stumped, try the general tricks.

! LaTeX Error: Unknown option . for package .

Check for typos and the package documentation.

documentclass must come before anything else nontrivial.

  1. Check for typos in the documentclass command.
  2. Put the documentclass before anything else besides comments and blank space.
  3. If stumped, try the general tricks.

! LaTeX Error: verb ended by end of line

  1. A verb must be of the form verb. where ! can be almost any character not inside . However, there may be no line breaks inside .
  2. Make sure that the start character, ! or whatever, is indeed the same as the end character.
  3. If stumped, try the general tricks.

! LaTeX Error: ! LaTeX Error: . undefined

Something that you treat as defined (say the command in a renewcommand) is not defined.

  1. Check for typos in the command, both here and where it was supposedly defined.
  2. Is the definition inside a comment block?
  3. If stumped, try the general tricks.

! Leaders not followed by proper glue

If you use leaders, you probably can figure this out.

By itself, an & can only be used in tables and the like to separate columns.

  1. If you want a printed &, use &. Example: Proctor & Gamble.
  2. A missing/misspelled begin or similar can cause this.
  3. If stumped, try the general tricks.

! Misplaced omit

The omit command overrides column formatting in tables and arrays and such.

  1. A multicolumn statement has an implied omit. Check its validity. In particular, whether it does not use more columns than there are defined.
  2. A newcommand within a tabular environment can cause this, I hear.
  3. If stumped, try the general tricks.

! Missing # inserted in alignment preamble

Usually, this happens to me if for some arcane reason I try to use a character like _ in the text. That can only be used in math mode (unless preceded by ). So Tex puts a dollar sign in front of it. Needless to say, that misplaced dollar sign will produce further errors. After all, the subsequent text is believed to be math, and the math following the next dollar sign to be text. (So a perfectly valid _ or ^ in that math produces the same error once again.)

  1. Use _ for an actual underscore and ^<> for a lone caret.
  2. Is something used in the text that can only be used in math mode? If so, enclose it between $ and $. Example: water is H$_2$O (superscripts and subscripts can only be used in math mode).
  3. Is a $ really missing from previous math?
  4. Math may not contain blank lines. If you leave a single blank line in an equation, it will generate the error message ! Missing $ inserted, followed by ! Display math should end with $$. followed by ! LaTeX Error: Bad math environment delimiter. Remove the blank line and all three error messages should disappear.
  5. Now latex2html has a nasty habit of leaving blank lines when it removes the labels from equations. These errors will then show up in its math images processing. In particular, they will show up in images.log. To fix this, put the label <. >in equations at the end, followed by a %. Furthermore, leave some mathematics on the same line, before the label<. >%.
  6. Remember that the inside of an mbox or hbox is not in math mode unless you enclose it between $ and $. Example: $alphabeta=0mbox< if $beta$ is zero>$ needs the $ signs around the second beta as shown.
  7. If stumped, try the general tricks.

! Missing $$ inserted

TeX has found that it should no longer be in display math mode. Note that in LaTeX you should be using [ and ], or begin and end, not $$ and $$.

  1. Blank lines are not allowed in math mode.
  2. If stumped, try the general tricks.

! Missing = inserted for .

LaTeX decided it really needed a < and inserted one.

  1. This is likely due to some earlier error.
  2. And the insertion is likely to introduce subsequent errors.
  3. Incorrect integral bounds can cause this error.
  4. If stumped, try the general tricks.

! Missing > inserted

LaTeX decided it really needed a > and inserted one.

  1. This is likely due to some earlier error.
  2. And the insertion is likely to introduce subsequent errors.
  3. Check for still-open opening brackets.
  4. If stumped, try the general tricks.

! Missing control sequence inserted

A control sequence means a LaTeX command, like backslash.

  1. It is [re]newcommand<name>. but [re]newenvironment. Note the backslash. In plain TeX, you have defname<. >.
  2. If stumped, try the general tricks.

! Missing delimiter inserted

Typically, this occurs when you put a in front of an environment name.

Missing «number» might actually be a length.

  1. Like it says? Check for presence and correctness of lengths and coordinates behind parbox, line, circle, put, .
  2. Remember that 0 is not a valid length. You must say 0in (inch) or 0pt (point) or something like it.
  3. A [..] may have been mistaken for an optional argument. If so, try enclosing it in brackets like <[. ]>. Like change \[text] into \<[text]>.
  4. A misplaced protect (before something like a length or a number) can also produce this error.
  5. If stumped, try the general tricks.

! Missing `to’ inserted

The «to» is not really used in LaTeX. It uses <> brackets for parameters.

Hyphenation words must consist of letters and hyphens.

  1. Using discretionary — hyphens in the actual word is probably the best way to keep LaTeX from nagging you.
  2. If stumped, try the general tricks.

! Number too big

Probably an indication that LaTeX is lost due to some error.

This should be very nasty, but I have never seen it.

Well, get the unused portion back.

Parameters of commands, unless defined specially, cannot contain blank lines.

  1. Check for a missing >.
  2. Check for blank lines inside parameters of commands.
  3. If stumped, try the general tricks.

! Parameters must be numbered consecutively

If you have this error, you probably know why.

  1. In latex, you do not normally use plain tex def definitions. If possible use [re]newcommand.
  2. If stumped, try the general tricks.

! Patterns can be loaded only by INITEX

I cannot imagine why any new user would want to load abstract hyphenation patterns.

TeX has noted that an argument of a command does not seem properly closed by a >.

  1. Check that each < has a proper closing >. Watch for mistaking ) for >.
  2. You cannot use a verbatim-line environment (like verbatim, rawhtml, comment, . ) inside something else. They need to stand alone. (Although I have used rawhtml inside a command definition. Nothing is absolute.)

! script. font . is undefined (character . )

In math mode, a special font is needed. It is not loaded

  1. Load it. Like load<footnotesize><sc>to load the sc (small caps) font in footnote size.
  2. If your installation has only limited fonts, you can probably do without.
  3. If stumped, try the general tricks.

! TeX capacity exceeded, sorry [. ]

Nowadays, this is likely to be something wrong with your document.

  1. Line excessively long? Various MS Windows-type software insists to put an entire paragraph of output on a single line in the input file. That can exceed the TeX input line buffer. In TeX, you should break up these long lines. To get a paragraph break, in TeX you use a blank line. Not just a line break.
  2. A missing > makes a parameter size explode?
  3. A circular definition? (Something defined in terms of itself?)
  4. Apparently, using some commands inside a fragile command can cause this. Try temporarily removing the contents.
  5. If stumped, try the general tricks.

! textfont . is undefined (character . )

In math mode, a special font is needed. It is not loaded

  1. Load it. Like load<textsize><sc>.
  2. If stumped, try the general tricks.

! Text line contains an invalid character

  1. Like it says? Check for weird characters in index.tex. Use a different editor if needed.
  2. If stumped, try the general tricks.

! This can’t happen (

Sometimes they are hard to count. Or you may have missed a <.

A command you are using is not defined by you, or the system.

  1. Did you misspell the command?
  2. Is whatever is supposed to define the command missing or misspelled? (Like the documentclass command, the usepackage<. >, the input<. >, or whatever?)
  3. Is the command used out of context? (Like an item not in a list?)
  4. Interestingly, a footnote inside a footnote can apparently cause this error.
  5. If stumped, try the general tricks.

! Use of . does not match its definition

You are using a valid command in the wrong way. In particular, the stuff immediately following the command is not in the right format. (A «command» might really be an environment.)

  1. Did you misspell the command?
  2. Check the proper command format in a LaTeX manual.
  3. Are you using the command itself right, but is something in its parameters not right? Like put(10,10) <line. >where the line. is invalid?
  4. Try using <> brackets around command parameters.
  5. If stumped, try the general tricks.

! You already have nine parameters

TeX macro definitions have a maximum of 9 arguments. (Being #1 to #9.) But you are unlikely to hit that limit as a new LaTeX user.

Источник

I’m trying to add a caption to a table in latex, however it throws this error «! LaTeX Error: caption outside float.»
From the error I am guessing it means that it is outside the table, but I have clearly put it inside.

begin{tabular}{|c|c|c|c|c|c|}
caption{Table1}
Potentiometer & Resistance  & multicolumn{2}{c}{Calculated Vtextsubscript{32}} & multicolumn{2}{c|}{Measured Vtextsubscript{32}}\ cline{3-6}
Position & Rtextsubscript{34} & Amplitude & Phase & Amplitude & Phase\ hline hline
1 & 303.8 & & 2.73 & 28.2 & 2.51\
2 & 1.141k & & 1.81 & 28.2 & 1.63\
3 & 3.453k & & 0.79 & 28.2 & 0.5\
4 & 5.33k & & 0.53 & 28.2 & 0.38\
5 & 7.45k & & 0.38 & 28.2 & 0.25\
6 & 9.54k & & 0.30 & 28.2 & 0.13\
7 & 10.84k & & 0.27 & 28.2 & 0.13\
hline
end{tabular}

asked Apr 29, 2009 at 17:38

Botto's user avatar

BottoBotto

1,1784 gold badges16 silver badges29 bronze badges

The tabular environment won’t take a caption. You need to do something like this:

begin{table}
begin{tabular}{|c|c|c|c|c|c|}
Potentiometer & Resistance  & multicolumn{2}{c}{Calculated Vtextsubscript{32}} & multicolumn{2}{c|}{Measured Vtextsubscript{32}}\ cline{3-6}
Position & Rtextsubscript{34} & Amplitude & Phase & Amplitude & Phase\ hline hline
1 & 303.8 & & 2.73 & 28.2 & 2.51\
2 & 1.141k & & 1.81 & 28.2 & 1.63\
3 & 3.453k & & 0.79 & 28.2 & 0.5\
4 & 5.33k & & 0.53 & 28.2 & 0.38\
5 & 7.45k & & 0.38 & 28.2 & 0.25\
6 & 9.54k & & 0.30 & 28.2 & 0.13\
7 & 10.84k & & 0.27 & 28.2 & 0.13\
hline
end{tabular}
caption{Table1}
label{tab:xyz}
end{table}

Will Robertson's user avatar

answered Apr 29, 2009 at 17:46

Dave's user avatar

DaveDave

10.2k1 gold badge38 silver badges34 bronze badges

2

If you don’t want to use a «float» (e.g. table or figure) that will «float away» from the place you define it, you can add:

usepackage{capt-of}

in the preamble and then do something like:

begin{center}
  captionof{table}{Caption text goes here}
  label{table1} % for use in ref{table1} if you want to refer to the table number
  begin{tabular}{|c|c|c|c|c|c|}
  % etc.
  end{tabular}
end{center}

to add a auto-numbered caption to a non-float.

gsamaras's user avatar

gsamaras

71k42 gold badges184 silver badges293 bronze badges

answered Apr 29, 2009 at 18:05

Jouni K. Seppänen's user avatar

Jouni K. SeppänenJouni K. Seppänen

42.3k5 gold badges72 silver badges100 bronze badges

5

latexteada

Hello :) this is going to be the last post about errors.

Talking about errors is essential because sometimes we have mistakes while writing, or we nest some forbidden inside other things, and if we do not know how to solve that error, we can not go further in our document.

I need to tell you that these errors are the most common ones, but there are many more, so if you are expanding your knowledge in the LaTeX world you will have other kinds of errors, and you can learn from them :)

Erros in the table environment

I am going to write the error in this format, the description of the error in this format and the possible solution in normal format

  • Extra alignment You have put an extra &, you forget the \ at the end of the row, you put a non-existing column number in cline{}

    • Delete the extra & or add another column
    • Put the \ at the end of the row
    • Check the number of columns that you have in your table and change the cline{} command
  • Misplaced alignment tab character& You put the & symbol in a wrong place while aligning, Change the position of & in your table environment

Errors in the figure environment

I am going to write the error in this format, the description of the error in this format and the possible solution in normal format

  • LaTeX Error: File myFigure not found The figure myFigure is either not available or not in a proper format

    • Check if the figure has the same name, remember that LaTeX is case-sensitive
    • Check if the figure is in the same folder where your .tex file is
    • Check if the extension of the figure that you want to put is compatible with the instruction that you are using
    • Check if the extension is the same as your figure
  • Illegal unit of measure You misspelled the unit measure in the includegraphics command or you use an unrecognized unit of measure

    • Check your spelling of the unit of measure
    • Check if the unit of measure that you are trying to use is allowed

Both environments

I am going to write the error in this format, the description of the error in this format and the possible solution in normal format

  • LaTeX Error: caption outside float You put the caption command outside table or figure environment Move the caption command inside the environments

Solution 1

The second table started with

begin{table}[h]

instead of

begin{table}[h]

meaning it missed a and that was what gave the error of a caption outside a float.

Solution 2

Check carefully your document when such errors pop out; before the editing to the question, the second begin{table} wasn’t preceded by the backslash. In this case LaTeX is happy to print «begintable[h]» and then start the center environment.

If you had proceded on by hitting return at the error message you’d have seen another one telling you that the document environment had been closed by table.

By the way, don’t use the center environment in this situation:

begin{table}
centering
<table data>
caption{The caption}label{thelabel}
end{table}

Comments

  • When I add the following table (table1 shown below) I don’t get any error, but when adding table2 (shown below) I get the error i)caption outside float. caption ii) Undefined control sequence caption. What is the difference between these two table definitions? These two seems same to me.

    latex code for table1 :

    begin{table}[h]
    begin{center}
    begin{tabular}{| p{2.5cm}| p{2.5cm} | p{2.5cm} |}
    hline
    textbf{AAA} & textbf{BBB} & textbf{CCC} \
    hline
    DDD   & 111 & 333\ hline
    EEE   & 222 & 444\ hline
    end{tabular}
    end{center}
    
    caption{Caption1}
    label{table1}
    
    end{table}
    

    ……………………………………………………….

    latex code for table2:

    begin{table}[h]
    begin{center}
    begin{tabular}{| p{2.5cm}| p{2.5cm} |}
    hline
    textbf{GGG} & textbf{HHH} \
    hline
    III                    &              113\ hline
    JJJ                    &              234\ hline
    KKK                    &              345\ hline
    end{tabular}
    end{center}
    caption{Caption2}
    label{table2}
    end{table}
    

    • The second lacks a in begin{table}[h].

    • I’m voting to close this question as off-topic because it is caused by a simple typo.

  • Should a table caption not be placed above the table? Not that this is made easy by LaTeX.

  • @MartinScharrer It’s a style decision. The standard classes provide for captions below in both cases (they set belowcaptionskip to zero). Think to a paper where there are tables and figures side by side: captions will be set all above or below. The caption package has the options position=top and position=bottom that can be set separately for figures and tables.

Recents

Понравилась статья? Поделить с друзьями:

Читайте также:

  • P31b8 leaf ошибка
  • Package authoring error access to path
  • P31b8 000b ev hev can error evc 287
  • Pack file consistency error
  • Pacify low error fatal error

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии