![花式盒子 tikz 没有出现在两列中](https://linux22.com/image/399363/%E8%8A%B1%E5%BC%8F%E7%9B%92%E5%AD%90%20tikz%20%E6%B2%A1%E6%9C%89%E5%87%BA%E7%8E%B0%E5%9C%A8%E4%B8%A4%E5%88%97%E4%B8%AD.png)
\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}