I would like to debug a latex macro, but I do not really know how. I got the following MWE which replaces the \\ in a string. I would like to print the value of generated string to check the result. The first output of \show is as expected \textbf {Test123\\Test234}. Now I would like to output the macro \addrGlobal, so that it shows \textbf {Test123\newline Test234}, but it does not work as expected. How can this output be archieved?

Thanks in advance!







  • You should add \usepackage{xstring}, and then I think you want to look at \addr (after invoking \addrGlobal), not \addrGlobal. Jul 20, 2013 at 17:29

1 Answer 1


There are various issues in your code.

  1. Why checking whether \address is empty? You have just defined it not to be
  2. \makeatletter and \makeatother are missing around the code that uses \@empty
  3. The string \empty\\ doesn't appear in \address, so nothing is changed.
  4. \addrGlobal will not contain a string, but rather \addr, when \addrGlobal is executed, which isn't in your code. Until you don't issue \addrGlobal, no value will be given to \addr.

Here's a possible fix.






Note \noexpand\\ in order not to expand the string to be searched and \exploregroups. The \ifx\@empty\address test is useless, because if the string is empty, no substitution will be performed.

Here is the output on the terminal:

> \address=macro:
->\textbf {Test123\\Test234}.
l.13 \show\address

> \addrGlobal=macro:
->\textbf {Test123\protect \newline  Test234}.
l.15 \show\addrGlobal

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .