Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to set up an environment to use for examples in my thesis document. I would like to increase margins, change the line spacing, open with "Example :", and close with $\Box$. Minipage works beautifully except I can't embed tables or figures within my examples.

This is what I have:

\newcounter{examplecounter}
\newenvironment{example}
{
\vspace{1.75em}
\begin{center}
    \begin{minipage}[h]{0.85\textwidth}
        \setlength{\parindent}{2em}
        \refstepcounter{examplecounter}
        \begin{oneandahalfspaced}
        \noindent
        \textbf{Example \arabic{examplecounter}:}
        }{
        \hspace{-1em}
        $\Box$
        \end{oneandahalfspaced}
    \end{minipage}
\end{center}
\vspace{1.75em}
}

Any suggestions on how to accomplish what I'm looking for?

share|improve this question
    
I tip about including other environments in \newenvironment s: Instead of e.g. \begin{center} ... \end{center} you can write \center ... \endcenter. This has the advantage that if the \end{example} is misplaced you get a proper warning, otherwise the name of most inner environment started with \begin{ will be printed, here: ! LaTeX Error: \begin{oneandahalfspaced} on input line XX ended by ... and people get confused because the never typed that environment by themselves. –  Martin Scharrer Feb 8 '11 at 10:02
    
Thanks for the tip Martin! –  Jason George Feb 8 '11 at 10:09

1 Answer 1

up vote 3 down vote accepted

You cannot have a figure environment inside a minipage because its a float, same counts for table. However you can include an image using \includegraphics (graphicx package) and also add a caption using the capt-of package: \captionof{figuree}{<the caption text>}.

See also this answer which explains float environments vs. their content as well.

share|improve this answer
2  
Martin, thanks for the quick answer and the reference. After reading the link I was able to get my table (minus the caption and reference label) using \begin{tabular} –  Jason George Feb 8 '11 at 10:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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