From 8c3fe251b1f9fc3912a857c53ea50585ae743b5a Mon Sep 17 00:00:00 2001
From: "Vladimir V. Kisil" <kisilv@maths.leeds.ac.uk>
Date: Sun, 16 Jul 2017 13:52:16 +0100
Subject: [PATCH 2/2] Introducing method symbol::get_TeX_name() to match
 existing symbol::get_name()

Signed-off-by: Vladimir V. Kisil <kisilv@maths.leeds.ac.uk>
---
 doc/tutorial/ginac.texi | 9 ++++++++-
 ginac/symbol.cpp        | 8 ++++++++
 ginac/symbol.h          | 1 +
 3 files changed, 17 insertions(+), 1 deletion(-)

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;
-- 
2.13.2

