2017-09-02 129 views
0

我是Tikz的新手,無法弄清楚爲什麼會有小幅度的tikzpictures將寬度擴展到整個頁面。 由於我希望我的文字在這些數字周圍浮動,因此知道如何防止它們擴大是非常有用的。防止擴大tikz圖片來包裝文字

這裏是我的問題的代碼和圖片,你可以看到它不是由長字幕引起的,我的第一個想法是什麼。

result of the code below

\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範圍的內容是什麼?

謝謝。

回答

1

這是默認行爲。您可以使用wrapfigure包以包裹tikz圖文字:

enter image description here

\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的數字)。

+0

是的。謝謝。使用wrapfig packege'\ usepackage {wrapfig}'後可以正常工作。 –