编辑

编辑

非常感谢。我可以使用您的评论来制作方框。我遇到的一个问题是如何对齐第一个和第二个方框(中国和 EE.UU.)。这是我的最小示例(我在每个方框中都写了所有文本,以便您更好地理解):

.....

    \tikzstyle{mybox} = [draw=blue!70!black, fill=blue!5!white, very thick,
        rectangle, rounded corners, inner sep=10pt, inner ysep=10pt]
    \tikzstyle{fancytitle} =[fill=blue!70!black, text=white]

    \begin{tikzpicture}

    % First box
    \node [mybox] (box1){%
        \begin{minipage}{0.30\textwidth}
        \begin{multicols}{2}   
          \small Alúmina\\Aluminio prim.\\Antimonio (P. M.)\\Arsénico blanco\\Barita\\Bismuto (P. M.)\\Cadmio\\Carbón\\Cobalto\\Cobre (P. R.)\\Cobre (P. F.)\\Fluorita\\Galio prim.\\Germanio metál.\\Oro (P. M.)\\Grafito\\Yeso\\Indio (P. R.)\\Hierro (mena)\\Arrabio\\Acero bruto\\Plomo (P. M.)\\Plomo (P. R.)\\
    Magnesita\\Megnesio metál. prim.\\Manganeso (mena)\\Mercurio\\Mica\\Molibdeno (P. M.)\\Níquel (P. R./P.F.)\\Perlita\\Roca fosfórica\\Óx. de tierras raras\\Sal\\Min. de estroncio\\Piritas\\Talco\\Estaño (P. M.)\\Estaño (P. F.)\\Tungsteno (P. M.)\\Vanadio (P. M.)\\Wollastonita\\Zinc (P. M.)\\Zinc (planchas)
        \end{multicols}
        \end{minipage}
    };
    \node[fancytitle] at (box1.north) {\textbf{China}};

    %
    \node [mybox,right=2mm of box1.58] (box2) {%
        \begin{minipage}[t!]{0.25\textwidth}
           \small Bentonita\\Tierra de batán\\Berilio\\Bromo\\Diatomita\\Caolín\\Gas natural\\Carb. de sodio natural\\Sulfuro (recuperado)\\Telurio metál.
        \end{minipage}
        };

% Now draw the fancy title (so that it is on top of the connection box)
\node[fancytitle] at (box2.north) {\textbf{EE.UU.}};

..... 

它工作得很好,但我就是无法找出框 2 中的下一个数字来与第一个数字对齐:58、57.9。我想我漏掉了什么?

非常感谢!!

答案1

请始终发布完整的示例。例如,我们不知道\textwidth是什么,甚至需要猜测编译某些东西所需的包和库。


由于您使用 指定了精确的对齐方式,因此不清楚您到底想要对齐什么.58。如果您希望框在顶部对齐,一种方法是使用.north eastanchor=north west

北对齐

\documentclass{article}
\usepackage{multicol,tikz}
\usetikzlibrary{positioning}
\tikzset{
  mybox/.style={draw=blue!70!black, fill=blue!5!white, very thick, rectangle, rounded corners, inner sep=10pt, inner ysep=10pt},
  fancytitle/.style={fill=blue!70!black, text=white},
}
\begin{document}
\begin{tikzpicture}
  % First box
  \node [mybox] (box1){%
    \begin{minipage}{0.30\textwidth}
      \begin{multicols}{2}
        \small Alúmina\\Aluminio prim.\\Antimonio (P. M.)\\Arsénico blanco\\Barita\\Bismuto (P. M.)\\Cadmio\\Carbón\\Cobalto\\Cobre (P. R.)\\Cobre (P. F.)\\Fluorita\\Galio prim.\\Germanio metál.\\Oro (P. M.)\\Grafito\\Yeso\\Indio (P. R.)\\Hierro (mena)\\Arrabio\\Acero bruto\\Plomo (P. M.)\\Plomo (P. R.)\\
        Magnesita\\Megnesio metál. prim.\\Manganeso (mena)\\Mercurio\\Mica\\Molibdeno (P. M.)\\Níquel (P. R./P.F.)\\Perlita\\Roca fosfórica\\Óx. de tierras raras\\Sal\\Min. de estroncio\\Piritas\\Talco\\Estaño (P. M.)\\Estaño (P. F.)\\Tungsteno (P. M.)\\Vanadio (P. M.)\\Wollastonita\\Zinc (P. M.)\\Zinc (planchas)
      \end{multicols}
    \end{minipage}
  };
  \node[fancytitle] at (box1.north) {\textbf{China}};
  \node [mybox, right=2mm of box1.north east, anchor=north west] (box2) {%
    \begin{minipage}[t!]{0.25\textwidth}
      \small Bentonita\\Tierra de batán\\Berilio\\Bromo\\Diatomita\\Caolín\\Gas natural\\Carb. de sodio natural\\Sulfuro (recuperado)\\Telurio metál.
    \end{minipage}
  };
  % Now draw the fancy title (so that it is on top of the connection box)
  \node[fancytitle] at (box2.north) {\textbf{EE.UU.}};
\end{tikzpicture}
\end{document}

但是,在我看来,这不是绘制此类框的最佳方法。您可能会发现使用类似 的方法要容易得多。在中tcolorbox嵌套多个列并不好……minipagenode

例如,上面的代码会产生不少于二十五坏盒子。使用\\来结束线路是部分原因 - 这不应该(几乎)永远不要在外部tabulararray环境等中使用。


以下是基于的替代方案。它使用以下语法为单列框tcolorbox设置新环境:listingbox

\begin{listingbox}[<additional options for box>]{<title>}
    <contents>
\end{listingbox}

或者使用带星号的版本的双列版本如下:

\begin{listingbox}*[<additional options for box>]{<title>}
    <column one>
    \tcblower
    <column two>
\end{listingbox}

然后你可以说:

\begin{listingbox}*[width=.4\textwidth]{China}
  Alúmina\par Aluminio prim.\par Antimonio (P. M.)\par Arsénico blanco\par Barita\par Bismuto (P. M.)\par Cadmio\par Carbón\par Cobalto\par Cobre (P. R.)\par Cobre (P. F.)\par Fluorita\par Galio prim.\par Germanio metál.\par Oro (P. M.)\par Grafito\par Yeso\par Indio (P. R.)\par Hierro (mena)\par Arrabio\par Acero bruto\par Plomo (P. M.)\par Plomo (P. R.)\par  Magnesita\par Megnesio metál. prim.
  \tcblower Manganeso (mena)\par Mercurio\par Mica\par Molibdeno (P. M.)\par Níquel (P. R./P.F.)\par Perlita\par Roca fosfórica\par Óx. de tierras raras\par Sal\par Min. de estroncio\par Piritas\par Talco\par Estaño (P. M.)\par Estaño (P. F.)\par Tungsteno (P. M.)\par Vanadio (P. M.)\par Wollastonita\par Zinc (P. M.)\par Zinc (planchas)
\end{listingbox}%
\hskip 2mm
\begin{listingbox}[width=.275\textwidth]{EE.UU.}
Bentonita\par Tierra de batán\par Berilio\par Bromo\par Diatomita\par Caolín\par Gas natural\par Carb. de sodio natural\par Sulfuro (recuperado)\par Telurio metál.
\end{listingbox}

生产:

蓝色列表框

完整代码:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins,xparse}
\DeclareTColorBox{listingbox}{ s O {} m }{%
  enhanced,
  title=#3,
  fonttitle=\bfseries,
  coltitle=white,
  top=10pt,
  bottom=10pt,
  left=10pt,
  right=10pt,
  boxsep=0pt,
  fontupper=\small,
  attach boxed title to top center={%
    yshift=-\tcboxedtitleheight/2,
    yshifttext=-\tcboxedtitleheight/2},
  boxed title style={%
    colframe=blue!70!black,
    colback=blue!70!black
  },
  colframe=blue!70!black,
  colback=blue!5!white,
  box align=top,
  nobeforeafter,
  IfBooleanTF={#1}{%
    sidebyside,
    sidebyside align=top,
    sidebyside gap=10pt,
    lower separated=false,
  }{},
  #2,
}
\begin{document}

\begin{listingbox}*[width=.4\textwidth]{China}
  Alúmina\par Aluminio prim.\par Antimonio (P. M.)\par Arsénico blanco\par Barita\par Bismuto (P. M.)\par Cadmio\par Carbón\par Cobalto\par Cobre (P. R.)\par Cobre (P. F.)\par Fluorita\par Galio prim.\par Germanio metál.\par Oro (P. M.)\par Grafito\par Yeso\par Indio (P. R.)\par Hierro (mena)\par Arrabio\par Acero bruto\par Plomo (P. M.)\par Plomo (P. R.)\par  Magnesita\par Megnesio metál. prim.
  \tcblower Manganeso (mena)\par Mercurio\par Mica\par Molibdeno (P. M.)\par Níquel (P. R./P.F.)\par Perlita\par Roca fosfórica\par Óx. de tierras raras\par Sal\par Min. de estroncio\par Piritas\par Talco\par Estaño (P. M.)\par Estaño (P. F.)\par Tungsteno (P. M.)\par Vanadio (P. M.)\par Wollastonita\par Zinc (P. M.)\par Zinc (planchas)
\end{listingbox}%
\hskip 2mm
\begin{listingbox}[width=.275\textwidth]{EE.UU.}
Bentonita\par Tierra de batán\par Berilio\par Bromo\par Diatomita\par Caolín\par Gas natural\par Carb. de sodio natural\par Sulfuro (recuperado)\par Telurio metál.
\end{listingbox}

\end{document}

编辑

对于与示例图像类似排列的许多框,您可以使用minipages 从多个框创建垂直列:

很多盒子

\documentclass[a4paper]{article}
\usepackage[scale=.85]{geometry}
\usepackage{tcolorbox}
\tcbuselibrary{skins,xparse}
\DeclareTColorBox{listingbox}{ s O {} m }{%
  enhanced,
  title=#3,
  fonttitle=\bfseries,
  coltitle=white,
  top=10pt,
  bottom=10pt,
  left=10pt,
  right=10pt,
  boxsep=0pt,
  fontupper=\small,
  attach boxed title to top center={%
    yshift=-\tcboxedtitleheight/2,
    yshifttext=-\tcboxedtitleheight/2},
  boxed title style={%
    colframe=blue!70!black,
    colback=blue!70!black
  },
  colframe=blue!70!black,
  colback=blue!5!white,
  box align=top,
  nobeforeafter,
  halign lower=left,
  halign upper=left,
  IfBooleanTF={#1}{%
    sidebyside,
    sidebyside align=top,
    sidebyside gap=10pt,
    lower separated=false,
  }{},
  #2,
}
\begin{document}
\noindent
\begin{listingbox}*[width=.35\textwidth]{China}
  Alúmina\par Aluminio prim.\par Antimonio (P. M.)\par Arsénico blanco\par Barita\par Bismuto (P. M.)\par Cadmio\par Carbón\par Cobalto\par Cobre (P. R.)\par Cobre (P. F.)\par Fluorita\par Galio prim.\par Germanio metál.\par Oro (P. M.)\par Grafito\par Yeso\par Indio (P. R.)\par Hierro (mena)\par Arrabio\par Acero bruto\par Plomo (P. M.)\par Plomo (P. R.)\par  Magnesita\par Megnesio metál. prim.
  \tcblower Manganeso (mena)\par Mercurio\par Mica\par Molibdeno (P. M.)\par Níquel (P. R./P.F.)\par Perlita\par Roca fosfórica\par Óx. de tierras raras\par Sal\par Min. de estroncio\par Piritas\par Talco\par Estaño (P. M.)\par Estaño (P. F.)\par Tungsteno (P. M.)\par Vanadio (P. M.)\par Wollastonita\par Zinc (P. M.)\par Zinc (planchas)
\end{listingbox}%
\hskip 2mm
\begin{minipage}[t]{.25\textwidth}
  \begin{listingbox}[width=.975\linewidth]{EE.UU.}
    Bentonita\par Tierra de batán\par Berilio\par Bromo\par Diatomita\par Caolín\par Gas natural\par Carb. de sodio natural\par Sulfuro (recuperado)\par Telurio metál.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{EE.UU.}
    Bentonita\par Tierra de batán\par Berilio\par Bromo\par Diatomita\par Caolín\par Gas natural\par Carb. de sodio natural\par Sulfuro (recuperado)\par Telurio metál.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{EE.UU.}
    Bentonita\par Tierra de batán\par Berilio\par Bromo\par Diatomita\par Caolín\par Gas natural\par Carb. de sodio natural\par Sulfuro (recuperado)\par Telurio metál.
  \end{listingbox}
\end{minipage}%
\hskip 2mm
\begin{minipage}[t]{.175\textwidth}
  \begin{listingbox}[width=.975\linewidth]{Chile}
    Something\par Something\par Something else\par One last thing.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{Australia}
    Something\par Something\par Something else\par One final thing.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{Canada}
    Something\par Something\par One last thing.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{Turkey}
    Something\par different.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{Greenland}
    Something\par Another thing.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{Iceland}
    Something\par Something\par Something else.
  \end{listingbox}\medskip
\end{minipage}%
\hskip 2mm
\begin{minipage}[t]{.175\textwidth}
  \begin{listingbox}[width=.975\linewidth]{Chile}
    Something\par Something\par Something else\par One last thing.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{Australia}
    Something\par Something\par Something else\par One final thing.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{Canada}
    Something\par Something\par One last thing.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{Turkey}
    Something\par different.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{Greenland}
    Something\par Another thing.
  \end{listingbox}\medskip

  \begin{listingbox}[width=.975\linewidth]{Iceland}
    Something\par Something\par Something else.
  \end{listingbox}\medskip
\end{minipage}
\end{document}

相关内容