Text FormattingText Alignment, equations alignment, and extra space!

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
amegahed3
Posts: 15
Joined: Wed Feb 25, 2009 11:20 am

Text Alignment, equations alignment, and extra space!

Post by amegahed3 »

Hi all,

I have a couple of questions concerning some formatting issues:

1. How can I custom align text? More specifically, suppose I wanna write this in Latex:

Code: Select all

For i=0 to 10, do
     while j=0 to 5, do
             If j=t+1, do
                change t to t-1
                Do other necessary modifications
             End if
   End while
End for
How can I write such a previous algorithm in that specific text alignment?

2. How can I align a set of equations to the left?

So, for instance the following code centers those 2 equations:

Code: Select all

 \begin {flalign}
 x=y+1 \\
 \sum\limits_{s \in S} X_s =10
 \end{flalign}
How can I make it align them to the left?

And how can I let any equation that begins with "==" be aligned with the previous "=" of the previous equation (not in the previous code)?

3. The following code leaves a wider big vertical space between the second enumeration and the italic word "Assumptions:" than the vertical space between the first enumeration and that same word:

Code: Select all

\begin{enumerate}
  \item \textbf{Column Generation procedure}\\
\noindent \emph{Assumptions:}
\begin{enumerate}
  \item No literature found!
  \item The routing paper.
 \end{enumerate}

\end{enumerate}
HOw can I avoid that extra space, and make that extra space between the first enumeration and "assumptions"?

I'd really appreciate any help.

Thanks a lot.

Aly

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Text Alignment, equations alignment, and extra space!

Post by gmedina »

Hi,

1) The verbatim environment can be an intial (and really basic) option. However, the listings package offers you a complete range of configurable options to write (pseudo)-code.

3) You can do something like this:

Code: Select all

\begin{enumerate}
  \item \textbf{Column Generation procedure}
  \item[] \emph{Assumptions:}\vspace*{-5pt}
  \begin{enumerate}
    \item No literature found!
    \item The routing paper.
  \end{enumerate}
\end{enumerate}
2) Do you want the left alignment to apply to all of your equations or just to some of them? Anyway, the amsmath package documentation can give you some ideas.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
christiem
Posts: 4
Joined: Wed Aug 05, 2009 8:23 pm

Text Alignment, equations alignment, and extra space!

Post by christiem »

1) The <algorithms> package is also very nice if you have to write a lot of pseudo-code.
http://www.ctan.org/tex-archive/macros/ ... lgorithms/

For example, try running this to get a version of your pseudo-code from above:

Code: Select all

\usepackage{algorithm,algorithmic}
\usepackage{amsmath}

\begin{document}

\begin{algorithm}
\caption{Calculate $y = x^n$}\label{alg1}
\begin{algorithmic}
\FOR{$i=0:10$}
    \WHILE{$j=0:5$}
        \IF{$j=t+1$}
            \STATE Change $t$ to $t-1$
            \STATE Do other necessary modifications
        \ELSIF{some other condition is true}
            \STATE do some different processing
        \ENDIF
    \ENDWHILE
\ENDFOR
\end{algorithmic}
\end{algorithm}

\end{document}
Post Reply