多列图片无法显示

多列图片无法显示

我有以下 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}

为什么在这种情况下figure内部不起作用?multicols

答案1

我将提出一种经过一整天思考后对我有用的方法。如果有任何编程级别的错误,请在评论中告诉我。

通过定义一个名为“two-column-figure”的新环境,IEtcfigure作为

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

现在,我可以将图形插入到我想要的位置,就像它是一个浮点数一样。完整代码如下:

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

相关内容