From: Vladimir V. Kisil Date: Mon, 17 Jul 2017 07:37:21 +0000 (+0200) Subject: Introducing method symbol::get_TeX_name() to match existing symbol::get_name(). X-Git-Tag: release_1-7-3~19 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=60dbeb45d93b9610c840eecc9b4d7f5a71f9ab5d;ds=sidebyside Introducing method symbol::get_TeX_name() to match existing symbol::get_name(). Signed-off-by: Vladimir V. Kisil --- diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index d5dbdd14..03365d05 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -1146,7 +1146,14 @@ This creates a symbol that is printed as "@code{x}" in normal output, but as "@code{\Box}" in LaTeX code (@xref{Input/output}, for more information about the different output formats of expressions in GiNaC). GiNaC automatically creates proper LaTeX code for symbols having names of -greek letters (@samp{alpha}, @samp{mu}, etc.). +greek letters (@samp{alpha}, @samp{mu}, etc.). You can retrive the name +and the LaTeX name of a symbol using the respective methods: +@cindex @code{get_name()} +@cindex @code{get_TeX_name()} +@example +symbol::get_name() const; +symbol::get_TeX_name() const; +@end example @cindex @code{subs()} Symbols in GiNaC can't be assigned values. If you need to store results of diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index 879461a4..c1256d56 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -157,6 +157,14 @@ std::string symbol::get_name() const return name; } +std::string symbol::get_TeX_name() const +{ + if (TeX_name.empty()) { + return get_default_TeX_name(get_name()); + } + return TeX_name; +} + // protected void symbol::do_print(const print_context & c, unsigned level) const diff --git a/ginac/symbol.h b/ginac/symbol.h index 91a9982a..1b9d3f8b 100644 --- a/ginac/symbol.h +++ b/ginac/symbol.h @@ -75,6 +75,7 @@ public: void set_name(const std::string & n) { name = n; } void set_TeX_name(const std::string & n) { TeX_name = n; } std::string get_name() const; + std::string get_TeX_name() const; protected: void do_print(const print_context & c, unsigned level) const; void do_print_latex(const print_latex & c, unsigned level) const;