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.

This line

~~Some~~thing

produces two leading spaces before the word 'Some' and the spaces before 'thing'.

However,

\texttt{~~Some~~thing}

does not produces the first two spaces (but produces the two spaces between the words).

Is there a way to force the leading spaces also when using \texttt?

share|improve this question
    
Welcome to TeX.SX! Would you please correct the code to show precisely what you're doing? –  egreg Oct 10 '11 at 14:15
    
Are you using that technique to get indented paragraphs? –  N.N. Oct 10 '11 at 14:19
    
@Sid: Note that typewriter font is mono-spaced. As such, the lengths of the characters (and spaces) are different to the normal (roman) character widths. To see that both actually produce the same spaces (albeit of different lengths), see \fbox{~~Some~~thing} and \fbox{\texttt{~~Some~~thing}}. –  Werner Oct 10 '11 at 14:23
    
I can't confirm this. Please provide an example. –  Christian Lindig Oct 10 '11 at 14:25
    
I am unsure about what actually happens to the spaces, but putting a box around it does produce them. So \mbox{\texttt{~~Some~~thing}} should work as you expect it. Although the indentation will be larger, because, as Werner has already mentioned, the spaces are larger since texttt is monospaced. –  Roelof Spijker Oct 10 '11 at 15:25

1 Answer 1

As egreg mentions, \texttt{~~Some} does produce leading spaces, so perhaps there was some other issue (such as paragraph indentation) messing up your experiment.

However, from the comments it appears that you are adding \textt just to include content that you don't want formatted and you want the leading spaces intacct. A simple way to do this is to use the verbatim environment:

enter image description here

\documentclass{article}
\begin{document}
\begin{verbatim}
Some thing
   Some more thing with leading spaces     and more space here
\end{verbatim}
\end{document}
share|improve this answer

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.