Text FormattingXelatex \,

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

Xelatex \,

Post by Laurentius »

I tried running Xelatex from the command line and entering

Code: Select all

\show\,
which returned

Code: Select all

> \,=macro:
->\x@protect \,\protect \,  .
What does this mean? To the uninitiated it looks like the macro is defined in terms of itself.

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Xelatex \,

Post by Johannes_B »

show can be very helpful, but if i know where a command is comming from, i go to the source and have a look.

Take a look at section 16.6 of source2e.pdf (horizontal space) or take at latex.ltx how \, is defined.

Code: Select all

\DeclareRobustCommand{\,}{%
   \relax\ifmmode\mskip\thinmuskip\else\thinspace\fi
}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Xelatex \,

Post by cgnieder »

\show with macros which are robust in the 2e-sense can be a bit frustrating: they usually have definitions like the one you're seeing:

Code: Select all

\show\foo
% > \foo=macro:
% ->\protect \foo  .
What is a bit hidden there is that the name of the internal command \foo includes a trailing space! In such cases a trick can help:

Code: Select all

\begingroup
\let\protect\show \foo
\endgroup
Locally redefine \protect to mean \show and then call the command.

In this very case we also need to disable \x@protect in a way that it eats the following \,:

Code: Select all

\documentclass{article}

\begin{document}

\show\,
% > \,=macro:
% ->\x@protect \,\protect \,  .

\begingroup\makeatletter
\let\x@protect\@gobble\let\protect\show\,
% > \, =\long macro:
% ->\relax \ifmmode \mskip \thinmuskip \else \thinspace \fi .
\endgroup

\end{document}
Regards
site moderator & package author
Post Reply