Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use xelatex, with Ubuntu font, and for some reason I can't insert a \textvisiblespace into my document - all that I get in result is a box: ``. Is there some way to fix that?

Example:

\documentclass[a4paper]{article}
\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{Ubuntu}
\begin{document}
\textvisiblespace
\end{document}
share|improve this question
    
\textvisiblespace does not use any fonts. It constructs the "space character" as 3 rules. What kind of warnings do you receive in your output/.log file? –  Werner Sep 22 '12 at 16:40
1  
@Werner - seems that it is not true - since the .log file contains this line: Missing character: There is no ␣ in font Ubuntu/ICU:mapping=tex-text,!. But I would be more than happy to draw it using three rules. How can I achieve this? –  Rogach Sep 22 '12 at 17:36
    
I've referenced a possible solution. It should work in your instance, but I'm unable to test it since I don't have the fonts installed. –  Werner Sep 22 '12 at 17:56
add comment

2 Answers

up vote 5 down vote accepted

The font Ubuntu doesn't support the Unicode character 2423. Use

\setmainfont[Mapping=tex-text]{DejaVu Serif}

for example. Another alternative maybe:

\documentclass[a4paper]{article}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Ubuntu}
\newfontface\TVSp{DejaVu Serif}
\def\textvisiblespace{{\TVSp\char"2423}}

\begin{document}
\textvisiblespace
\end{document}
share|improve this answer
    
That's sad, I like that font. But maybe you can suggest more conventional font? I'm writing a technical documentation text, that would be probably read on computer screen. –  Rogach Sep 22 '12 at 17:45
    
see edited answer. However, Ubuntu is similiar to Bera Sans –  Herbert Sep 22 '12 at 17:46
    
Thanks! Your suggestions worked perfectly. –  Rogach Sep 22 '12 at 17:55
    
+1, but I suggest \protected\def. It's true that \TVSp will be "robust", but it's perhaps more desirable to write \textvisiblespace in case it appears in a moving argument. –  egreg Sep 22 '12 at 18:03
    
And where is the problem, if it appears for example in a \caption command?? –  Herbert Sep 22 '12 at 18:17
add comment

I don't have the font installed, so I'm not sure whether this is what you're after:

  1. Redefine \textvisiblespace after loading the Ubuntu font. The following definition is taken from latex.ltx:

    \def\textvisiblespace{%
       \mbox{\kern.06em\vrule height.3ex}%
       \vbox{\hrule width.3em}%
       \hbox{\vrule height.3ex}}
    
  2. Capture the contents of \textvisiblespace in a box before loading the new font and restore it afterwards:

    % Document preamble
    \newsavebox{\textvisiblespacebox}
    \begin{lrbox}{\textvisiblespacebox}\textvisiblespace\end{lrbox}
    % Insert font-related changes here
    \def\textvisiblespace{\usebox{\textvisiblespacebox}}
    

    Note that this will fix the setting of \textvisiblespace in \normalfont, so it won't change with size changes like \small (for example).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.