Scissor LaTeX 中的 TikZ
TikZ 套件在 Scissor LaTeX 中可用於常用的功能,由它自己繪製:線條、形狀、圓弧、曲線、格線、有名稱和錨點的節點、箭頭、positioning 函式庫、\foreach、scope 和顏色;\matrix、\pic、裝飾、圖樣、矩形和圓形以外的節點形狀,以及 tikz-cd、circuitikz 和 forest 圖目前還不支援。
套件的用途
TikZ 是 LaTeX 的繪圖語言。在 tikzpicture 中,你可以寫 \draw (0,0) -- (2,1); 這樣的路徑,把文字放在節點中,用箭頭連接節點,並用 \foreach 重複繪製。用 \usetikzlibrary 載入的函式庫會增加相對位置(positioning)、箭頭樣式(arrows.meta)和座標運算(calc)等功能。
Scissor LaTeX 不會執行 TikZ。排版器讀取圖的內容,自己以向量圖形繪製,節點文字則使用文件的字型。
在這裡可用的功能
| 功能 | 在 Scissor LaTeX 中 | 更多資訊 |
|---|---|---|
\draw、\fill、\filldraw、\path、行內的 \tikz 指令 | 可用 | TikZ 基礎 |
--, -|, |-, rectangle, circle, ellipse, arc, grid, .. controls .., to[out=,in=] | 可用 | TikZ 基礎 |
極座標、相對座標(+、++)和具名座標,(A.north) 這類錨點 | 可用 | |
($(A)!0.5!(B)$) 這類 calc 中點 | 可用 | 只支援中點和 +/-。 |
\node, \coordinate, draw, fill, text width, align, minimum size | 可用 | 節點和箭頭 |
節點形狀 rectangle 和 circle | 可用 | ellipse 會畫成圓形,沒有訊息;其他形狀(diamond、star ...)會畫成矩形,並顯示訊息。 |
positioning:right=of A、below=1cm of A、node distance | 可用 | |
箭頭 ->、<->、-stealth、-latex、-{Stealth} | 可用 | 箭頭尖端和 TikZ 相近,但不完全相同。 |
顏色、混色(red!50!blue)、線寬、虛線樣式、不透明度、rounded corners | 可用 | 請見 xcolor。 |
scope, scale, shift, rotate, every node/.style, \tikzset | 可用 | |
使用清單、範圍、配對和 count 的 \foreach | 可用 | |
使用矩形或圓形的 \clip | 可用 | 其他裁剪路徑會被忽略並顯示訊息。 |
裝飾、let 路徑、name intersections | 不支援 | 會被忽略並顯示訊息;路徑以一般方式繪製。 |
pattern=... | 部分支援 | 繪製成淺色填色,並顯示「patterns are drawn as a light fill」訊息。 |
\matrix, \pic | 不支援 | 圖會變成虛線框,並顯示訊息。 |
tikz-cd、circuitikz、forest 圖 | 不支援 | 會被略過,並顯示訊息。 |
| 有座標軸的圖表 | 可用 | 請使用 pgfplots。 |
範例
用 positioning 函式庫放置、以箭頭連接的具名節點:
節點、positioning 和箭頭
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, arrows.meta}
\begin{document}
\begin{tikzpicture}[node distance=1.2cm,
box/.style={draw, rounded corners, minimum width=2cm}]
\node[box] (data) {Data};
\node[box, right=of data] (model) {Model};
\node[box, right=of model] (report) {Report};
\draw[-{Stealth}] (data) -- (model);
\draw[-{Stealth}] (model) -- (report);
\node[below=0.3cm of model] {44 runs};
\end{tikzpicture}
\end{document}行內的小圖,以及用 \foreach 重複繪製的形狀:
\foreach 和行內 \tikz
Status: \tikz \fill[green!60!black] (0,0) circle (3pt); online.
\begin{tikzpicture}
\foreach \x/\c in {0/red, 1/orange, 2/yellow, 3/green, 4/blue} {
\fill[\c] (\x, 0) rectangle ++(0.8, 0.8);
\node at (\x + 0.4, -0.3) {\x};
}
\end{tikzpicture}節點的 \matrix 不支援。圖會被換成一個說明此情況的虛線框:
\matrix 不會繪製
\begin{tikzpicture}
\matrix[draw] {
\node {A}; & \node {B}; \\
\node {C}; & \node {D}; \\
};
\end{tikzpicture}「問題」分頁: \matrix in a picture is not supported yet
相容性
- 從 TeX 安裝環境搬到這裡:在上述範圍內的圖,看起來和在那裡一樣。不支援的選項會在「問題」分頁中列出,圖的其餘部分仍會繪製。tikz-cd 的交換圖、電路圖和樹狀圖會被略過。
- 從這裡搬到 TeX 安裝環境:圖在那裡搭配 TikZ 不需修改就能編譯。
TikZ 手冊是 CTAN 上 PGF 的一部分:ctan.org/pkg/pgf。交換圖:tikz-cd。
常見問題
需要載入 TikZ 函式庫嗎?
和在任何 LaTeX 文件中一樣,寫上 \usetikzlibrary{...}。Scissor LaTeX 會接受這一行,所以文件在其他地方也能編譯;無論有沒有寫出函式庫名稱,支援的功能都能用。
為什麼我的 TikZ 圖是虛線框?
這張圖使用了目前還不支援的功能,例如 \matrix 或 \pic。框中的文字和「問題」分頁會列出是哪個功能。
可以繪製交換圖嗎?
目前還不能用 tikz-cd:這類圖會被略過。簡單的圖可以用節點和箭頭繪製,或在數學式中用 \begin{array} 和箭頭寫出來。
本頁的每個範例都在建置網站時由 Scissor LaTeX 排版。 最後更新:2026-11-07