LaTeX forum ⇒ Text Formattingnode 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

Postby kent » Wed Mar 27, 2019 10:36 am

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.

Your best,
Kent Holing
Attachments
testing-mgnodetxt.tex
(1.08 KiB) Downloaded 52 times

rais
Posts: 209
Joined: Sun Nov 16, 2014 8:51 pm

Postby rais » Wed Mar 27, 2019 8:30 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)):
  1. \def\mylntxt[#1,#2,#3]{\MGnodetext[#1,#2,{#3},black,left,1]}
  2. \mylntxt[A,a,{D = (x_0,y_0)}];

KR
Rainer

kent
Posts: 55
Joined: Thu Oct 20, 2016 3:41 pm

Postby kent » Thu Mar 28, 2019 10:39 am

Thanks indeed. It works, ;)


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 2 guests