4

I am trying to add a picture using:

\begin{figure}[!h!t]
    \centering
        \includegraphics[width=90mm]{Hollywood and Beverly Hills}
    \caption{Hollywood and Beverly Hills}
    \label{fig: h&bh}
\end{figure} 

but am getting the error:

! Argument of \@xfloat has an extra }.
<inserted text> 
                \par 
l.15 \begin{figure}[!h!t]

?

I want it so that the picture appears at the beginning of the document in a section that is not twocolumn, so I tried using two @columnfalse but I can't get it to work.

Here is a minimal example of my document:

\documentclass[twocolumn,12pt]{article}
\usepackage{graphicx}
\usepackage{setspace}
\doublespacing

\begin{document}

\pagestyle{plain}
\twocolumn[
\begin{@twocolumnfalse}
\begin{center}
\section*{Neighborhoods}
\end{center}


\begin{figure}[!h!t]
    \centering
        \includegraphics[width=90mm]{neighborhoods}
    \caption{Hollywood and Beverly Hills}
    \label{fig: hbh}
\end{figure} 

\vspace{.25 in}
\end{@twocolumnfalse}]

\section*{Hollywood}

\section*{Beverly Hills}

\end{document}

Can someone help me fix this?

8
  • You will receive (useful) help faster, as a rule, if you provide a minimal example (or here)
    – jon
    Nov 19 '13 at 19:05
  • 2
    If I put that fragment onto a document I get no error, please always provide a complete document that shows the problem. having two ! in the argument is an error really but the second is silently ignored, so that is not the problem. That particular error was quite common 20 years ago if code designed for latex209 was used with latex2e, but it is pretty rare these days, Nov 19 '13 at 19:17
  • My guess is that you have spaces in the file name. Try renaming the image file. Nov 19 '13 at 19:18
  • Another issue, might be the & in the label.. does not look right, & is a special character in LaTeX, should not be used in labels. Nov 19 '13 at 19:19
  • 2
    @Paxinum neither of your comments can apply, as the error shows the position as \begin{figure} so TeX hasn't seen the graphic filename or label Nov 19 '13 at 19:22
8

You can not have a floating environment inside the optional argument of \twocolumn also you need to hide inner [] from any LaTeX optional argument by using a brace group. [{... [...]...}]

\documentclass[twocolumn,12pt]{article}
\usepackage[demo]{graphicx}% [demo] as I have not got the figure
\usepackage{setspace}
\doublespacing
\usepackage{capt-of}

\begin{document}

\pagestyle{plain}
\twocolumn[{

\section*{Neighborhoods}

    \centering
        \includegraphics[width=90mm]{neighborhoods}
    \captionof{figure}{Hollywood and Beverly Hills}
    \label{fig: hbh}

\vspace{.25 in}
}]

\section*{Hollywood}

\section*{Beverly Hills}

\end{document}
0
0

The \twocolumn macro looks for an optional argument by checking if the next token is [. Therefore the rogue [ after \twocolumn upsets LaTeX enormously. Delete it, and your document will (probably) compile.

2
  • @ Ian Thompson, If I delete those brackets though then that section becomes part of the column which I don't want. Any ideas?
    – Logan
    Nov 19 '13 at 21:25
  • @Logan --- please edit your question and explain exactly what you do want. Nov 19 '13 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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