编辑:我确实编写了此文档:
\documentclass[DIV14,parskip=half-]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{showframe}
\begin{document}
\fbox{\begin{tikzpicture}
\tkzDefPoint(0, 0){A}
\tkzDefPoint(4, 0){B}
\tkzDefPoint(6, 3.5){C}
\tkzDefPoint(2, 3.5){D}
\draw (0, 0) node[below left] {A} -- (4, 0) node[below right] {B} -- (6, 3.5) node[above right] {C} -- (2, 3.5) node[above left] {D} -- cycle;
\tkzCircumCenter(A,B,D)
\tkzGetPoint{O}
\tkzDrawCircle(O,A)
\tkzCircumCenter(A,C,D)
\tkzGetPoint{O}
\tkzDrawCircle(O,A)
\end{tikzpicture}}
\end{document}
并得到以下输出:
这段代码,TiKZ 生成的图片高度几乎是需要的两倍。图片上方是一大片空白。它是从哪里来的?
原始代码:
\documentclass[DIV14,parskip=half-]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
\draw (0, 0) grid (10, 10);
\tkzDefPoint(0, 0){A}
\tkzDefPoint(4, 0){B}
\tkzDefPoint(6, 3.5){C}
\tkzDefPoint(2, 3.5){D}
\draw (0, 0) node[below left] {A} -- (4, 0) node[below right] {B} -- (6, 3.5) node[above right] {C} -- (2, 3.5) node[above left] {D} -- cycle;
\tkzCircumCenter(A,B,D)
\tkzGetPoint{O}
\tkzDrawCircle(O,A)
\tkzCircumCenter(A,C,D)
\tkzGetPoint{O}
\tkzDrawCircle(O,A)
\end{tikzpicture}
\end{document}
答案1
不需要的空白来自命令\tkzCircumCenter(...)
。使用不可见的路径来构造圆心。它放大了边界框。
您可以使用软件包修补此命令etoolbox
\usepackage{etoolbox}
\pretocmd\tkzCircumCenter{\begin{pgfinterruptboundingbox}}{}{}
\apptocmd\tkzCircumCenter{\end{pgfinterruptboundingbox}}{}{}
代码:
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{etoolbox}
\pretocmd\tkzCircumCenter{\begin{pgfinterruptboundingbox}}{}{}
\apptocmd\tkzCircumCenter{\end{pgfinterruptboundingbox}}{}{}
\begin{document}
\fbox{\begin{tikzpicture}
\tkzDefPoint(0, 0){A}
\tkzDefPoint(4, 0){B}
\tkzDefPoint(6, 3.5){C}
\tkzDefPoint(2, 3.5){D}
\draw (0, 0) node[below left] {A} -- (4, 0) node[below right] {B} -- (6, 3.5) node[above right] {C} -- (2, 3.5) node[above left] {D} -- cycle;
\tkzCircumCenter(A,B,D)
\tkzGetPoint{O}
\tkzDrawCircle(O,A)
\tkzCircumCenter(A,C,D)
\tkzGetPoint{O}
\tkzDrawCircle(O,A)
\end{tikzpicture}}
\end{document}