9

Using the suggestions from this answer, I decided to use \pgfuseplotmark to make marks in my diagram. However, there is some strange white space inserted to the left of the pgfmarks. What should I do to remove it? Here's an MWE:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{plotmarks}

\begin{document}

\begin{tikzpicture}
  \node[draw] at (0,0) {!};
  \node[draw] at (2,0) {\pgfuseplotmark{diamond*}};
\end{tikzpicture}

\end{document}
mbork
  • 13,385

1 Answers1

15

Because of the missing % at the end of the plotmark drawing commands in the library. Usually, \pgfuseplotmark is used as a standalone command and not put in the text boxes so the inherent TikZ feature of eating up regular font via \nullfont takes care of it. But it becomes apparent once you put them in text aware places such as the box of a node.

Quick way to fix is

\node[draw] at (2,0) {\nullfont\pgfuseplotmark{diamond*}};

or if you are disturbed deeply and want to have it done properly

\documentclass[tikz]{standalone}
\usetikzlibrary{plotmarks}
\pgfdeclareplotmark{diamond*}
{%
  \pgfpathmoveto{\pgfqpoint{0pt}{\pgfplotmarksize}}% <-- These % are missing in the originals
  \pgfpathlineto{\pgfqpoint{.75\pgfplotmarksize}{0pt}}%
  \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}}%
  \pgfpathlineto{\pgfqpoint{-.75\pgfplotmarksize}{0pt}}%
  \pgfpathclose%
  \pgfusepathqfillstroke%
}
\begin{document}
\begin{tikzpicture}
\node[draw] {\pgfuseplotmark{diamond*}};
\end{tikzpicture}
\end{document}

enter image description here

percusse
  • 157,807