
我只了解 TikZ 的基礎知識,只用它為我的一份文件產生了一個漂亮的流程圖。我最近了解到您可以使用 Inkscape 並將其匯出到 TikZ。
Inkscape->TikZ 工作流程有哪些限制?是否有一些令人信服的理由花時間學習 TikZ(我聽說它有一個相當陡峭的學習曲線)而不是簡單地從 Inkscape 導出到 TikZ?
答案1
編輯:@XiaodongQi 在下面評論
新版本的 Inkscape 中不再提供相同的選項。但儲存 PDF 時也有類似的選項。
您可以將 inkscape 圖形儲存為 pdf 並將其放入帶有\includegraphics
.如果您的圖中有文本,您可以從 inkscape 另存為 pdf 選單中選擇 PDF+LaTeX 選項。這將建立一個 pdf_tex 檔案。您\input
將該文件並由 TeX 進行排版。
在墨景中:
選擇另存為 pdf 後從 inkscape 儲存。 Inkscape 寫入檔案topview.pdf_tex
:
在文件中:
\begin{figure}[h]
\centering{
\resizebox{75mm}{!}{\input{images/topview.pdf_tex}}
\caption{Top view.}
\label{fig:topView}
}
\end{figure}
輸出:
這顯然是一張可以用 tikz 繪製的圖片,但我選擇不這樣做,原因是您在回复 @HarishKumar 時闡明的 - tikz 學習曲線較長以及偶爾使用所見即所得的偏好。如果您確實需要精確的放置(線條確實在角落相交),您也許可以使用 inkscape 的對齊功能來做到這一點。我還沒有嘗試過這些。
答案2
導出後(由 Ethan Bolker 描述),使用以下程式碼片段嵌入 Inscape 產生的圖像:
\begin{figure}
\def\svgwidth{\linewidth}
\input{img/filename.pdf_tex}
\caption{}
\end{figure}
用意志\def\svgwidth{desired width}
代替\resizebox
意志保留字體大小。這是生成文件的頭部描述的建議方式:
%% Creator: Inkscape 0.91_64bit, www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file '_masks.pdf' (pdf, eps, ps)
%%
%% To include the image in your LaTeX document, write
%% \input{<filename>.pdf_tex}
%% instead of
%% \includegraphics{<filename>.pdf}
%% To scale the image, write
%% \def\svgwidth{<desired width>}
%% \input{<filename>.pdf_tex}
%% instead of
%% \includegraphics[width=<desired width>]{<filename>.pdf}
%%
%% Images with a different path to the parent latex file can
%% be accessed with the `import' package (which may need to be
%% installed) using
%% \usepackage{import}
%% in the preamble, and then including the image with
%% \import{<path to file>}{<filename>.pdf_tex}
%% Alternatively, one can specify
%% \graphicspath{{<path to file>/}}
%%
%% For more information, please see info/svg-inkscape on CTAN:
%% http://tug.ctan.org/tex-archive/info/svg-inkscape
%%
答案3
作為另一種選擇,有一個工具SVG2TikZ(以前是Inkscape2TikZ),可用於產生TikZ程式碼。
如果您從 GitHub 儲存庫安裝 Python 套件,則可以使用 TikZ 將 SVG(可從 Inkscape 匯出)轉換為 TeX 原始程式碼,如下所示:
svg2tikz a.svg > a.tex
它還可以作為 Inkscape 擴充功能安裝。