我有用 KvMap 包编写的这个 K-Map,但我不知道如何正确地将其居中:
\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{kvmap}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{center}
\begin{kvmap}
\kvlist{8}{4}{\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},\phantom{0},X,X,X,X,X,X,X,X,\phantom{0},1,1,\phantom{0},X,X,X,\phantom{0}}{Q_2, Q_1, Q_0 ,Q_4 , Q_3 }
\foreach \tikzn/\tikzi in {00/0, 10/1, 20/3, 30/2, 40/6, 50/7, 60/5, 70/4,
01/8, 11/9, 21/11, 31/10, 41/14, 51/15, 61/13, 71/12,
02/24, 12/25, 22/27, 32/26, 42/30, 52/31, 62/29, 72/28,
03/16, 13/17, 23/19, 33/18, 43/22, 53/23, 63/21, 73/20
}
{\node[font=\footnotesize,anchor=north east, inner sep=0.25pt] at (\tikzn.north east) {$\tikzi$};}
\begin{scope}[on background layer]
\fill[gray!30] (1,-2) rectangle (3,-4);
\fill[gray!30] (5,-2) rectangle (7,-4);
\end{scope}
\end{kvmap}
\end{center}
\end{document}
我希望 Kmap 的左侧和右侧有相同的空间。
答案1
kvmap是居中。然而,你认为它没有出现居中,因为眼睛是由垂直规则引导的。
你可以告诉 TeX 备份标签的宽度问4问3插入负空间。
\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{calc}
\usepackage{kvmap}
\usetikzlibrary{backgrounds}
\usepackage{showframe} % just to show the margins, remove it
\begin{document}
\begin{center}
\settowidth{\dimen0}{$Q_4Q_3$}\hspace*{-\dimen0}%
\begin{kvmap}
\kvlist{8}{4}{\phantom{0},\phantom{0},\phantom{0},\phantom{0},
\phantom{0},\phantom{0},\phantom{0},\phantom{0},
\phantom{0},\phantom{0},\phantom{0},\phantom{0},
\phantom{0},\phantom{0},\phantom{0},\phantom{0},
X,X,X,X,X,X,X,X,\phantom{0},1,1,\phantom{0},X,X,X,
\phantom{0}}
{Q_2, Q_1, Q_0, Q_4, Q_3}
\foreach \tikzn/\tikzi in {
00/0, 10/1, 20/3, 30/2, 40/6, 50/7, 60/5, 70/4,
01/8, 11/9, 21/11, 31/10, 41/14, 51/15, 61/13, 71/12,
02/24, 12/25, 22/27, 32/26, 42/30, 52/31, 62/29, 72/28,
03/16, 13/17, 23/19, 33/18, 43/22, 53/23, 63/21, 73/20
}
{
\node[font=\footnotesize,anchor=north east, inner sep=0.25pt] at (\tikzn.north east) {$\tikzi$};
}
\begin{scope}[on background layer]
\fill[gray!30] (1,-2) rectangle (3,-4);
\fill[gray!30] (5,-2) rectangle (7,-4);
\end{scope}
\end{kvmap}
\end{center}
\end{document}