
對於 TikZ,我是一個完全的初學者,所以請原諒我的一些愚蠢行為。
我想要 TikZ 一個字段塔,但是內部標籤和邊緣的距離太大。我想減少這一點。有沒有一種簡單的方法可以實現這一點,而無需重寫整個程式碼?我之前尋找過答案,但我發現的所有問題要么略有不同,要么答案完全偏離主題(至少對我來說)。
這是一個最小的工作範例:
\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc} % input encoding
\usepackage[T1]{fontenc} % use T1 fonts for font encoding
\usepackage{amsfonts} % math font
\usepackage{tikz}
\newcommand{\Fr}{\textbf{F}}
\newcommand{\F}{\mathbb{F}}
\begin{document}
\begin{center}
\begin{tikzpicture}[node distance = 2cm, auto]
\node (F3) {$\F_3$};
\node (F33) [above of=F3, left of=F3] {$\F_{3^3}$};
\node (F32) [above of=F3, right of=F3] {$\F_{3^2}$};
\node (F36) [above of=F3, node distance = 4cm] {$\F_{3^6}$};
\node (F318)[above of=F33, node distance = 4cm] {$\F_{3^{18}}$};
\node (F39) [above of=F33, left of=F33] {$\F_{3^9}$};
\draw[-] (F3) to node {3} (F33);
\draw[-] (F3) to node [swap] {2} (F32);
\draw[-] (F32) to node [swap] {3} (F36);
\draw[-] (F33) to node {2} (F36);
\draw[-] (F33) to node {3} (F39);
\draw[-] (F36) to node [swap] {3} (F318);
\draw[-] (F39) to node {2} (F318);
\draw (F3) to node [swap] {$\langle \Fr \rangle$} (F33);
\draw (F3) to node {$\langle \Fr \rangle$} (F32);
\draw (F32) to node {$\langle \Fr^2 \rangle$}(F36);
\draw (F33) to node [swap] {$\langle \Fr^3\rangle$} (F39);
\draw (F33) to node [swap] {$\langle \Fr^3\rangle$} (F36);
\draw (F36) to node {$\langle \Fr^6\rangle$} (F318);
\draw (F39) to node [swap] {$\langle \Fr^9\rangle$} (F318);
\end{tikzpicture}
\end{center}
\end{document}
答案1
一個笨拙的解決方案:
\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc} % input encoding
\usepackage[T1]{fontenc} % use T1 fonts for font encoding
\usepackage{amsfonts} % math font
\usepackage{tikz}
\newcommand{\Fr}{\textbf{F}}
\newcommand{\F}{\mathbb{F}}
\begin{document}
\begin{center}
\begin{tikzpicture}[
node distance = 2cm, auto,
every node/.style = {inner sep=1pt,outer sep=0pt},
vrtc/.style = {inner sep=3pt}]
\node (F3) [vrtc] {$\F_3$};
\node (F33) [vrtc,above of=F3, left of=F3] {$\F_{3^3}$};
\node (F32) [vrtc,above of=F3, right of=F3] {$\F_{3^2}$};
\node (F36) [vrtc,above of=F3, node distance = 4cm] {$\F_{3^6}$};
\node (F318)[vrtc,above of=F33, node distance = 4cm] {$\F_{3^{18}}$};
\node (F39) [vrtc,above of=F33, left of=F33] {$\F_{3^9}$};
\draw[-] (F3) to node {3} (F33);
\draw[-] (F3) to node [swap] {2} (F32);
\draw[-] (F32) to node [swap] {3} (F36);
\draw[-] (F33) to node {2} (F36);
\draw[-] (F33) to node {3} (F39);
\draw[-] (F36) to node [swap] {3} (F318);
\draw[-] (F39) to node {2} (F318);
\draw (F3) to node [swap] {$\langle \Fr \rangle$} (F33);
\draw (F3) to node {$\langle \Fr \rangle$} (F32);
\draw (F32) to node {$\langle \Fr^2 \rangle$}(F36);
\draw (F33) to node [swap] {$\langle \Fr^3\rangle$} (F39);
\draw (F33) to node [swap] {$\langle \Fr^3\rangle$} (F36);
\draw (F36) to node {$\langle \Fr^6\rangle$} (F318);
\draw (F39) to node [swap] {$\langle \Fr^9\rangle$} (F318);
\end{tikzpicture}
\end{center}
\end{document}
在上面的程式碼中,我將所有節點的內部分離減少到 1pt 並定義 node vrtc
,在其中我將其返回到 3pt。