我应如何更改mybox
下面定义的样式以使其适合第二列?
\documentclass[twocolumn,11pt]{article}
\usepackage{tikz}
\usepackage{lipsum}
\tikzstyle{mybox} = [draw=black, very thick, rectangle, rounded corners, inner ysep=5pt, inner xsep=5pt]
\begin{document}
\lipsum[2-4]
\vspace{10pt}\begin{tikzpicture}
\node [mybox] (box){
\begin{minipage}{.96\textwidth}
\textbf{lipsum[2-4] -} In this example, lipsum package is used to print dummy text below chapter title. lipsum[2-4] prints lorem ipsum text from paragraph 2 to paragraph 4.
\end{minipage}
};
\end{tikzpicture}
\end{document}
答案1
mybox
溢出,因为您为 提供的宽度minipage
大于0.96\textwidth
( linewidth
=0.5* \textwidth
)。请将宽度减小到0.5*\textwidth
或以下。或者,使用\linewidth
代替\textwidth
。
\documentclass[twocolumn,11pt]{article}
\usepackage{tikz}
\usepackage{lipsum}
\tikzstyle{mybox} = [draw=black, very thick, rectangle, rounded corners, inner ysep=5pt, inner xsep=5pt]
\begin{document}
\lipsum[2-4]
\vspace{10pt}\begin{tikzpicture}
\node [mybox] (box){
\begin{minipage}{.96\linewidth}
\textbf{lipsum[2-4] -} In this example, lipsum package is used to print dummy text below chapter title. lipsum[2-4] prints lorem ipsum text from paragraph 2 to paragraph 4.
\end{minipage}
};
\end{tikzpicture}
\end{document}
答案2
我建议使用tcolorbox
而不是TikZ
节点:
\documentclass[twocolumn,11pt]{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\newtcolorbox{mybox}{colback=white, size=fbox, colframe=black, boxrule=1.2pt}
\begin{document}
\lipsum[2-4]
\begin{mybox}
\textbf{lipsum[2-4] -} In this example, lipsum package is used to print dummy text below chapter title. lipsum[2-4] prints lorem ipsum text from paragraph 2 to paragraph 4.
\end{mybox}
\end{document}