【问题标题】:Prevent expanding tikz picture to wrap text around防止扩展 tikz 图片以环绕文本
【发布时间】:2017-09-02 23:37:10
【问题描述】:

我是 Tikz 的新手,无法弄清楚为什么相对较小的 tikzpictures 会将其宽度扩展到整个页面。 由于我希望我的文本围绕这些数字浮动,因此知道如何防止它们扩展将非常有用。

这是我的问题的代码和图片,你可以看到它不是由长标题引起的,这是我的第一个想法。

\section{demo}

\begin{figure}[h]
    \tdplotsetmaincoords{60}{25}
    \begin{tikzpicture}[tdplot_main_coords, scale=1]
    \coordinate (o) at (0,0,0);
    \coordinate (x) at (4,0,0);
    \coordinate (y) at (0,0,4);
    \coordinate (z) at (0,-4,0); 

    \node[above] at (x) {x};
    \node[above] at (y) {y};
    \node[above] at (z) {z};

    \draw[red, -latex] (o) -- (x);
    \draw[green, -latex] (o) -- (y);
    \draw[blue, -latex] (o) -- (z);

    \end{tikzpicture}
    \caption{far to long caption for this kind of sensless figure created just for demonstrationg tikzpicture expand their width}

\end{figure}

\begin{figure}[h]
    %[... same code as above ...]   
\end{figure}

你们有什么建议可以让 tikzpicture 边界适应内容吗?

谢谢。

【问题讨论】:

    标签: latex figure floating tikz


    【解决方案1】:

    这是默认行为。您可以使用 wrapfigure 包将文本环绕在 tikz 图形周围:

    \begin{wrapfigure}{r}{0.4\textwidth}
        \tdplotsetmaincoords{60}{25}
        \begin{tikzpicture}[tdplot_main_coords, scale=1]
            ...
        \end{tikzpicture}
        \caption{far to long caption for this kind of sensless figure created just for demonstrationg tikzpicture expand their width}
    \end{wrapfigure}
    

    \begin{wrapfigure}{r}{0.4\textwidth}中,第一个参数是位置(r代表右边),第二个参数是wrapfigure的大小(这里40%的页面宽度适合tikz图)。

    【讨论】:

    • 是的。谢谢你。使用 wrapfig packege \usepackage{wrapfig} 后工作正常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-18
    • 1970-01-01
    • 2010-12-15
    • 1970-01-01
    • 1970-01-01
    • 2014-10-08
    相关资源
    最近更新 更多