0

I have the following MWE

\documentclass{article}
\usepackage{lipsum}
\usepackage{color}
\usepackage{multicol}

%-> Defining the INFORMATION environment:
\newenvironment{info}[1]
    {\setlength{\parindent}{0cm}
    \color{black!75}
    \bigskip\par
    \textbf{#1}
    \small

    }{\bigskip\par}
    %... info environment is for info that aids solving the problems


\begin{document}

\section{Introduction}
\lipsum[1]

\section{Theory}
\lipsum[11]

\begin{info}{A square}
\begin{multicols}{2}
Observe below that I can draw a square using the \textit{tikz} package.

\begin{center}
    \rule{2cm}{2cm}
\end{center}

However, I can't show this inside a \textit{picture} environment. Believe me, there should be another square below.

\begin{figure}
    \centering
        % \begin{tikzpicture}
        %     \draw
        %         (0, 0) circle(2)
        %         ;
        % \end{tikzpicture}
        \rule{2cm}{2cm}
    \caption{There should be a cricle here.}
    \label{F circle}
\end{figure}
\end{multicols}
\end{info}


\section{Conclusions}
Can't draw inside a \textit{multicol} environment, and I just don't know why.

\end{document}

Why figure doesn't work inside multicols in this case?

  • 2
    multicol and figures might be interesting – leandriis May 2 '19 at 15:46
  • 2
    Multicols does not support floats (figure and table). It does however support full width floats (figure* and table*). This point was not explicitly stated in the linked question/answers. – John Kormylo May 2 '19 at 16:18
0

I will propose an approach that worked for me after all day long thinking about this issue. Please, tell me in comments if there is any programming level mistake.

By defining a new environment called "two-column-figure", i.e., tcfigure as

%-> Defining the TWO-COLUMN-FIGURE environment:
\newenvironment{tcfigure}{%
    \begin{center}
    \begin{tabular}{ c }
    }{%
    \end{tabular}
    \end{center}
    }

%-> Defining the TWO-COLUMN-FIGURE CAPTION command:
\newcommand{\tcfcaption}[1]{%
    \\
    \begin{tabular}{ p{0.33\textwidth} }
    \footnotesize
    Figure \refstepcounter{figure}\thefigure: #1
    \end{tabular}
    }

I can now insert a figure where I desire as if it were a float. The complete code follows:

\documentclass{article}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{multicol}

%-> Defining the INFORMATION environment:
\newenvironment{info}[1]
    {\setlength{\parindent}{0cm}
    \color{black!75}
    \bigskip\par
    \textbf{#1}
    \small
    }{\bigskip\par}
    %... info environment is for info that aids solving the problems

%-> Defining the TWO-COLUMN-FIGURE environment:
\newenvironment{tcfigure}{%
    \begin{center}
    \begin{tabular}{c}
    }{%
    \end{tabular}
    \end{center}
    }

%-> Defining the TWO-COLUMN-FIGURE CAPTION command:
\newcommand{\tcfcaption}[1]{%
    \\
    \begin{tabular}{ p{0.33\textwidth} }
        \footnotesize
        Figure
        \refstepcounter{figure}%
        \thefigure: #1
    \end{tabular}
    }


\begin{document}

\section{Introduction}
\lipsum[1]

\section{Theory}
\lipsum[11]

\begin{info}{A square}
\begin{multicols}{2}
Observe below that I can draw a square using the \textit{bar} command, as shown below.

\begin{center}
    \rule{2cm}{2cm}
\end{center}

However, I can't show this inside a \textit{picture} environment. Believe me, there should be another square below.

\begin{tcfigure}
        \rule{2cm}{2cm}
    \tcfcaption{%
        There should be a square here. And in fact, now there is!
        \label{F square}}
\end{tcfigure}
\end{multicols}
\end{info}


\section{Conclusions}
Can't draw inside a \textit{multicol} environment, and I just don't know why. But it is possible to create a new enviroment that mimics the \textit{figure} one. See it in figure~\ref{F square}.

\end{document}
| improve this answer | |

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.