## LaTeX forum ⇒ Text Formatting ⇒ node labels in PGF Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
kent
Posts: 55
Joined: Thu Oct 20, 2016 3:41 pm

### node labels in PGF

I often need to put labels on nodes in my figures using PGF.

I wrote wrapper macros to achieve this to minimize code (and code copying).
My problem is that although these macros work fine as long as the label (text) does not
contain a , (comma) because thisÿ leads to a wrong number of arguments. (No surprise.)

Say, the macro has 3 arguments where the last argument defines the label, as
\def\mgoutputlabel[#1,#2,#3]{..};

Then:
\mgoutputlabel[A,B,x_0^2]; works fine, but
\mgoutputlabel{A,B,D = (x_0,\;y_0)] does not work (error message issued), so I tried
\mgoutputlabel[A,B,D = (x_0\,\;y_0)] where the macro outputs the label without issuing an
error message, but the label output is D = (x_0 y_0) with the , ignored.

Anyway to fix this? I would like to get the output D = (x_0, y_0).)

The attached file contains the a simple complete case to illustrate this.

Kent Holing
Attachments
testing-mgnodetxt.tex

rais
Posts: 189
Joined: Sun Nov 16, 2014 8:51 pm
Hi,
you need to put the comma-containing parameter in extra braces (in both places: when you call it in \mylntxt, as well as within its definition (the #3 is surrounded by commata, after all)):
\def\mylntxt[#1,#2,#3]{\MGnodetext[#1,#2,{#3},black,left,1]}\mylntxt[A,a,{D = (x_0,y_0)}];

KR
Rainer

kent
Posts: 55
Joined: Thu Oct 20, 2016 3:41 pm
Thanks indeed. It works,