LaTeX - adding a different amount of horizontal spacing to the beginning of each new line in a sequence

I use LaTeX to assign algorithms, and I need to show the steps for the Horspool algorithm to match strings, similar to what is shown in the tutorial. The way he demonstrates the algorithm shows how the pattern is shifted along the text for each failed comparison, with each shift on a new line. The figure is shown below the text with the corresponding horizontal spacing indicating which letters are compared.

Here is an example of how it would look with a DNA sequence:

GAGTAATCCTTCACTTCAAGGCCAGTCTTCACATCTCATCAGA ACATCTCA ACATCTCA ACATCTCA ACATCTCA 

I talked a few links to LaTeX. I tried using \hspace to add an interval at the beginning of each line, then adding \hfill after the pattern and before creating a new line. I do not get any errors, but there is no place at the front. The line is filled correctly.

Is there another way to add a space at the beginning of each line or another way to format this?

+6
formatting latex spacing
source share
4 answers

I'm sure you want to type your examples using a fixed-width font, in which case you should probably use the verbatim framework. Even better, you can use the fancyvrb package, which gives you the verbatim environment and allows you to control subtitles, coloring, font / shape size, etc. You can even make spaces more visible by showing them:

 \documentclass{article} \usepackage{fancyvrb} \begin{document} \begin{Verbatim}[showspaces=true,fontsize=\small] GAGTAATCCTTCACTTCAAGGCCAGTCTTCACATCTCATCAGA ACATCTCA ACATCTCA ACATCTCA ACATCTCA \end{Verbatim} \end{document} 
+7
source share

Just use \hspace*{5mm} (ie star shape), which works great at the beginning of a line.

+23
source share

To do this, I always add an "empty" object to the beginning of the line, for example.

 ${}$\hspace{5em}Foo 

it is not beautiful, but serves a purpose.

+3
source share

I would just use a list of ads and indent with spaces or tabs. I suppose you still use a typewriter font to get letters with relative widths.

0
source share

All Articles