# weird output using foreach command

So I am trying to familiarize myself with tikz \foreach command through this link Yet something strange happened. According the the linke, if I am trying to iterize two variable at the same time instead of one after the other, I should use / to separate the two. Thus a code like

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


should yield

“1 and 2”“a and b”


But when I typed in the exact same code, instead I got a bland page.

Here is my code for reproducing purpose:

\documentclass{article}
\usepackage{tikz}

\begin{document}

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

\end{document}


Thanks for the help in advance.

• Why \tikz? You aren’t drawing a picture. May 20, 2020 at 8:10
• \tikz just drops the text as it is not in a node. Either drop \tikz, or use nodes.
– user194703
May 20, 2020 at 8:11

If I compile your example code, I find in the log file

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!


which means that TeX is indeed trying to typeset the letters, but since it is in the middle of a tikzpicture, it has been instructed to use the nullfont, which is an internal font that has no character at all and produces no interword space either.

If I remove \tikz and the semicolon, I get

• Thanks. I didn't know Tizpicture environment doesn't allow text, May 20, 2020 at 9:25