当将我的 tikz 图像嵌入到不同类型的文档类中时,我遇到了一些非常烦人的差异。我提供了以下 MWE:
\documentclass[
]{book}
%]{scrbook}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [rounded corners, fill=green!10] (-4,0) node [anchor=north west]{xXxXxXxXxXxXx} rectangle (4,-3);
\node[draw] (n1) { node 1};
\node[below of=n1, draw] (n2) { node 1};
\node[below right of=n2, draw] (n3) { node 1};
\end{tikzpicture}
\end{document}
使用时book
我得到:
但scrbook
我得到:
不幸的是,我不得不对 tikz 图片使用这两类文档。我该如何消除位移?任何帮助都将不胜感激!
答案1
运行示例时,book
类输出
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-08-07>
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/book.cls
Document Class: book 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/bk10.clo))
请注意,它告诉您它使用的是 10pt 字体。scrbook
另一方面:
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-08-07>
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/scrbook.cls
Document Class: scrbook 2020/07/22 v3.31 KOMA-Script document class (book)
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/scrbase.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/scrlfile.sty)))
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/scrsize11pt.clo)
看到它默认使用 11pt 了吗?
不同的字体大小会导致文本的宽度不同,因此您应该使用相同的字体大小来生成相同的图像。