当前的问题与我的另一个问题相关,TikZ 和 tikzorbital:背景问题在上一个问题中,层的问题已经确定:
我所需要的只是填充矩形宽度变为\columnwidth
。如果您感兴趣,为什么我需要它,我使用填充的标题,我需要展位图片填充宽度和标题填充宽度变为\columnwidth
。但是您不需要在 MWE 中创建填充的标题:使用文本作为测量值。
\documentclass[a4paper]{article}
\usepackage[x11names]{xcolor}
\usepackage{tcolorbox}% no need in this mwe
\usepackage[font=small]{caption}% no need in this mwe
\usepackage{float}% no need in this mwe
\usepackage{floatflt}% no need in this mwe
\usepackage{tikz}
\usepackage{tikzorbital}
\usetikzlibrary{fadings,patterns,backgrounds,fit,arrows}
\pgfdeclarelayer{backbackground}
\pgfsetlayers{backbackground,background,main}
\usepackage{lipsum}
\oddsidemargin=-10.4mm %
\evensidemargin=-20.4mm %
\topmargin=-24mm %
\textwidth=190mm %
\textheight=275mm %
\headheight = 5mm %
\headsep = 4mm
\footskip = 8mm
\begin{document}
\twocolumn
\lipsum[1-2]
\begin{figure}[ht!]
\centering
\begin{tikzpicture}
\begin{scope}[font=\itshape]% to not type it every time, but better go for math mode
\draw[-latex] (0,0)--(1,0) node[above]{x};
\draw[-latex] (0,0)--(-0.5,-0.7) node[above]{y};
\draw[-latex] (0,0)--(0,1) node[above]{z};
\orbital[pos = {(0,0)}]{py}
\node[above] at (0.7,0.7) {p$_x$};
\draw[-latex] (3,0)--(4,0) node[above]{x};
\draw[-latex] (3,0)--(2.5,-0.7) node[above]{y};
\draw[-latex] (3,0)--(3,1) node[above]{z};
\orbital[pos = {(3,0)}]{px}
\node[above] at (3.7,0.7) {p$_y$};
\draw[-latex] (6,0)--(7,0) node[above]{x};
\draw[-latex] (6,0)--(5.5,-0.7) node[above]{y};
\draw[-latex] (6,0)--(6,1) node[above]{z};
\orbital[pos = {(6,0)}]{pz}
\node[above] at (6.7,0.7) {p$_z$};
\end{scope}
% correctly setting the background layer
\begin{pgfonlayer}{backbackground}
\fill[LightBlue1](current bounding box.south west)rectangle
(current bounding box.north east);
\end{pgfonlayer}
\end{tikzpicture}
\caption{This is the test of the caption} \end{figure}
\lipsum[3-7]
\end{document}
答案1
您可以添加一个带有 的虚拟节点来minimum width=\columnwidth
填充整个列。同样,将标题括在节点内并进行一些调整。另一方面,如果您正在加载caption
包,您也可以使用\captionof
宏。
\documentclass[a4paper]{article}
\usepackage[x11names]{xcolor}
\usepackage{tcolorbox}% no need in this mwe
\usepackage[font=small]{caption}% no need in this mwe
\usepackage{float}% no need in this mwe
\usepackage{floatflt}% no need in this mwe
\usepackage{tikz}
\usepackage{tikzorbital}
\usetikzlibrary{fadings,patterns,backgrounds,fit,arrows}
\pgfdeclarelayer{backbackground}
\pgfsetlayers{backbackground,background,main}
\usepackage{lipsum}
\oddsidemargin=-10.4mm %
\evensidemargin=-20.4mm %
\topmargin=-24mm %
\textwidth=190mm %
\textheight=275mm %
\headheight = 5mm %
\headsep = 4mm
\footskip = 8mm
\begin{document}
\twocolumn
\lipsum[1-2]
\begin{figure}[ht!]
\centering
\begin{tikzpicture}
\begin{scope}[font=\itshape]% to not type it every time, but better go for math mode
\draw[-latex] (0,0)--(1,0) node[above]{x};
\draw[-latex] (0,0)--(-0.5,-0.7) node[above]{y};
\draw[-latex] (0,0)--(0,1) node[above]{z};
\orbital[pos = {(0,0)}]{py}
\node[above] at (0.7,0.7) {p$_x$};
\draw[-latex] (3,0)--(4,0) node[above]{x};
\draw[-latex] (3,0)--(2.5,-0.7) node[above]{y};
\draw[-latex] (3,0)--(3,1) node[above]{z};
\orbital[pos = {(3,0)}]{px}
\node[above] at (3.7,0.7) {p$_y$};
\draw[-latex] (6,0)--(7,0) node[above]{x};
\draw[-latex] (6,0)--(5.5,-0.7) node[above]{y};
\draw[-latex] (6,0)--(6,1) node[above]{z};
\orbital[pos = {(6,0)}]{pz}
\node[above] at (6.7,0.7) {p$_z$};
\end{scope}
\node[minimum width=\columnwidth] at (current bounding box.center){}; %% this node is dummy
% correctly setting the background layer
\begin{pgfonlayer}{backbackground}
\fill[LightBlue1](current bounding box.south west)rectangle
(current bounding box.north east);
\end{pgfonlayer}
\end{tikzpicture}
\tikz[baseline=1ex]\node[text width=\columnwidth,fill=LightBlue1,text height=-2ex,inner sep=0pt]{\caption{This is the test of the caption This is the test of the caption This is the test of the caption}}; %% caption inside a node.
\end{figure}
\lipsum[3-7]
\end{document}