Text Formattingnode labels in PGF

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

node labels in PGF

Post by kent »

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 253 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

node labels in PGF

Post by rais »

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)):

Code: Select 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: 57
Joined: Thu Oct 20, 2016 3:41 pm

node labels in PGF

Post by kent »

Thanks indeed. It works, ;)
Post Reply