\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
%\usepackage[spanish]{babel}
\usepackage[spanish,es-nodecimaldot]{babel}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{pstricks}
\usepackage{multicol} %%%multiples columnas
\usepackage[left=2.5cm,top=2cm,right=2.5cm,bottom=2cm]{geometry}
\usepackage[affil-it]{authblk}
\usepackage{natbib}
\usepackage{tikz}
\usepackage[tikz]{bclogo}
\usepackage{ragged2e}
\justifying
\usepackage[skins,theorems]{tcolorbox}
\tcbset{highlight math style={enhanced,
colframe=red,colback=white,arc=0pt,boxrule=1pt}}
\newcommand{\mybox}[4]{
\begin{figure}[h]
\centering
\begin{tikzpicture}
\node[anchor=text,text width=\columnwidth-1.2cm, draw, rounded corners, line width=1pt, fill=#3, inner sep=5mm] (big) {\\#4};
\node[draw, rounded corners, line width=.5pt, fill=#2, anchor=west, xshift=5mm] (small) at (big.north west) {#1};
\end{tikzpicture}
\end{figure}
}
\begin{document}
\begin{multicols}{2}
\mybox{Interferencia}{blue!40}{blue!10}{El término interferencia se refiere a cualquier situación en la que dos o más ondas se traslapan en el espacio}
\end{multicols}
\end{document}
答案1
为了让您的框出现在 multicols 环境中,只需figure
从您的定义中删除\mybox
:
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
%\usepackage[spanish]{babel}
\usepackage[spanish,es-nodecimaldot]{babel}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{pstricks}
\usepackage{multicol} %%%multiples columnas
\usepackage[left=2.5cm,top=2cm,right=2.5cm,bottom=2cm]{geometry}
\usepackage[affil-it]{authblk}
\usepackage{natbib}
\usepackage{tikz}
\usepackage[tikz]{bclogo}
\usepackage{ragged2e}
\justifying
\usepackage[skins,theorems]{tcolorbox}
\tcbset{highlight math style={enhanced,
colframe=red,colback=white,arc=0pt,boxrule=1pt}}
\newcommand{\mybox}[4]{
%\begin{figure}[h]
\centering
\begin{tikzpicture}
\node[anchor=text,text width=\columnwidth-1.2cm, draw, rounded corners, line width=1pt, fill=#3, inner sep=5mm] (big) {\\#4};
\node[draw, rounded corners, line width=.5pt, fill=#2, anchor=west, xshift=5mm] (small) at (big.north west) {#1};
\end{tikzpicture}
%\end{figure}
}
\begin{document}
\begin{multicols}{2}
\mybox{Interferencia}{blue!40}{blue!10}{El término interferencia se refiere a cualquier situación en la que dos o más ondas se traslapan en el espacio}
\end{multicols}
\end{document}