# [texhax] How to put space characters at the beginning of a line?

José Romildo Malaquias j.romildo at gmail.com
Tue Apr 27 21:28:04 CEST 2010

On Tue, Apr 27, 2010 at 04:59:12PM +0100, Robin Fairbairns wrote:
> José Romildo Malaquias <j.romildo at gmail.com> wrote:
>
> > I need to put space characters at the beginning of a line in a LaTeX
> > document. The problem is that neither '~' nor '\ ' works to achieve this
> > behaviour.
> >
> > See the simplified document that illustrates the problem:
> >
> >    \documentclass[a4paper]{article}
> >
> >    \begin{document}
> >
> >    \ttfamily\frenchspacing\noindent
> >    First~line\newline
> >    ~~Second~line
> >
> >    \end{document}
> >
> > Note that, when this document is compiled, the letter 'S' in the last
> > line aligns to the letter 'F' in the previous line. How can I get this
> > 'S' aligned to the 'r' front the previous line?
> >
> > This problem should be solved without using the verbatim (or similar)
> > environment.
>
> so you want verbatim without the verbatim environment, but don't explain
> what you don't like about the environment.
>
> how about copying the code of the verbatim environment?
>
> verbatim text in tex is notoriously tricky, which is why the verbatim
> environment is so complicated.  there are various scraps of verbatim
> code on the macros/plain and macros/generic trees on ctan; iirc there's
> one in the texbook, too.  all those that work will have essentially the
> same code as the verbatim environment.  (the \obeyspaces, \obeylines stuff.)

I am working on some changes to the minted LaTeX package.  This package
is used to highlight source code snippets in a LaTeX document. It uses
the Pygments external project to do actual highlighting.

Environments similar to verbatim from the fancyvrb package are used to
insert the highlighted source code snippets into the final document.
But the explicit use of those environments are making some features
very hard to deal with. So I want to explore other options. That is
the reason I currently want to avoid them.

Basically the contents of minted environment are scanned using some
macros from the fancyvrb package and saved to an auxiliary file. Then an
external program process the auxiliary file doing the highlighting of
those code snippets, generating a second auxiliary file. In the next run
of LaTeX those highlighted code snippets are inserted back into the
document. I am have difficulties doing some formatting at these stage.

In the second auxiliary file, which is a LaTeX package itself, each
highlighted code snippet is implemented as a saved verbatim, which is a
feature from the fancyvrb package. Then, at the second pass through
LaTeX, these saved verbatim are put at the right spot using the
environment UseVerbatim from fancyvrb.

With this procedure, there are some problems. For instance, line
numbered (also a feature from the fancyvrb) does not work. All lines are
numbered equal, using the number of the last line for all lines of the
code snippet.

I hope this make it more clear what I am dealing with.

Romildo