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'm confused in how I might go about writing a command to create an indention in LaTeX.

For example, I am making an outline, and I want the Main Points to have an \hspace of 30pt. How do I create a command (\main) that will allow me to do that consistently throughout my document?

I am trying to learn LaTeX, but even this simple task is eluding me.

\newcommand{\main}          %% I know this is wrong
{
     \hspace{30pt}
}
share|improve this question
    
The first row of each paragraph has been indented by default. If you need to change the indentation space, modify the existing indentation space definition at the preamble. The change will be reflected throughout the document automatically. –  xport Jun 7 '11 at 14:08
add comment

migrated from stackoverflow.com Jun 7 '11 at 13:54

This question came from our site for professional and enthusiast programmers.

2 Answers

If you need that your paragraph introduced by \main is exactly 30pt from the left margin, you can define

\newcommand{\main}{\par\noindent\hspace*{30pt}\ignorespaces}

With \par you are sure to start a new paragraph, with \noindent you disable the automatic indentation, with \hspace*{30pt} you insert the desired spacing. I've added \ignorespaces though it's not necessary here because if you try a different definition, for instance by adding a title in bold face, with

\newcommand{\main}[1]{\par\noindent\hspace*{30pt}%
  \textbf{#1}\enspace\ignorespaces}

you don't incur in the spurious space that would be introduced by an input such as

\main{Item} text

without \ignorespaces.

You should consider, however, a list environment, for your outline. For example

\newenvironment{outline}
  {\begin{list}{}{\setlength{\leftmargin}{30pt}}}
  {\end{list}}

and input your items as

 \begin{outline}
 \item First element
 \item Second element
 ...
 \end{outline}
share|improve this answer
add comment

You should be able to use the built in \indent if you want to indent individual paragraphs. If you want LaTeX to automatically indent the start of all starting paragraphs, you can use the indentfirst package to indent the first paragraph. And if you want to change the indentation length you can use \setlength{\parindent}{0.25in}

share|improve this answer
add comment

Your Answer

 
discard

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