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?

Logan
  • 141
  • 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, – David Carlisle Nov 19 '13 at 19:17
  • My guess is that you have spaces in the file name. Try renaming the image file. – Per Alexandersson 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. – Per Alexandersson 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 – David Carlisle Nov 19 '13 at 19:22
  • @jon thanks here is what the document looks like:

    \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}

    – Logan Nov 19 '13 at 19:47
  • Update your question; don't post large chunks of code in comments. – Svend Tveskæg Nov 19 '13 at 19:52
  • why include twocolumn after pagestyle when twocolumn options was already specified? – doed Nov 19 '13 at 20:03

2 Answers2

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}
David Carlisle
  • 757,742
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.

Ian Thompson
  • 43,767