使用 foreach 命令的奇怪输出

使用 foreach 命令的奇怪输出

因此,我尝试通过以下方式熟悉 tikz \foreach 命令此链接然而奇怪的事情发生了。根据链接,如果我尝试同时迭代两个变量而不是一个接一个地迭代,我应该使用/来区分两者。因此,像这样的代码

\foreach \x / \y in {1/2,a/b} {``\x\ and \y''}

应该屈服

“1 and 2”“a and b”

但当我输入完全相同的代码时,我得到的却是一个平淡无奇的页面。

下面是我用于重现目的的代码:

\documentclass{article}
\usepackage{tikz}


\begin{document}

\tikz
\foreach \x / \y in {1/2,a/b} {``\x\ and \y''};



\end{document}

我在这里先向您的帮助表示感谢。

答案1

如果我编译你的示例代码,我会在日志文件中找到

Missing character: There is no ` in font nullfont!
Missing character: There is no ` in font nullfont!
Missing character: There is no 1 in font nullfont!
Missing character: There is no a in font nullfont!
Missing character: There is no n in font nullfont!
Missing character: There is no d in font nullfont!
Missing character: There is no 2 in font nullfont!
Missing character: There is no ' in font nullfont!
Missing character: There is no ' in font nullfont!
Missing character: There is no ` in font nullfont!
Missing character: There is no ` in font nullfont!
Missing character: There is no a in font nullfont!
Missing character: There is no a in font nullfont!
Missing character: There is no n in font nullfont!
Missing character: There is no d in font nullfont!
Missing character: There is no b in font nullfont!
Missing character: There is no ' in font nullfont!
Missing character: There is no ' in font nullfont!
Missing character: There is no ; in font nullfont!

这意味着 TeX 确实在尝试排版这些字母,但由于它位于 的中间tikzpicture,因此它被指示使用nullfont,这是一种内部字体,它根本没有字符,也不会产生单词间空格。

如果我删除\tikz分号,我会得到

在此处输入图片描述

相关内容