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 want to write RULES in main body, how to write the correct TeX code that guarantees a little larger space before and after RULES like this.

sample image

share|improve this question
    
Welcome to TeX.sx! I added the theorem tag as your rules are a theorem-like element. If you disagree, feel free to remove the tag. –  Torbjørn T. Feb 18 '13 at 7:05

2 Answers 2

up vote 9 down vote accepted

A from-scratch definition for such "RULE"s is easy:

enter image description here

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\newcounter{rules}
\newenvironment{rules}
  {\par\medskip\refstepcounter{rules}%
   \normalfont RULE~\therules.\quad\itshape\ignorespaces}
  {\par\medskip}
\begin{document}
\begin{rules}
\lipsum*[1]
\end{rules}
\lipsum*[2]
\begin{rules}
\lipsum*[3]
\end{rules}
\lipsum*[4]
\end{document}

The rules environment inserts a gap above & below equivalent to \medskip (which is 6pt plus 2pt minus 2pt or \medskipamount). A gap of \quad (or 1em) is inserted between the RULE #. and the starting italicized text. It can also be referenced using \label-\ref, if needed.

lipsum provided dummy text, Lorem Ipsum style.


Indentation of the first paragraph of the rule environment can be avoided by using \noindent:

%...
\newenvironment{rules}
  {\par\medskip\refstepcounter{rules}%
   \noindent\normalfont RULE~\therules.\quad\itshape\ignorespaces}
  {\par\medskip}
%...

For more elaborate paragraph indentation management, consider using the parskip package.

share|improve this answer
    
It is a great answer. I want to know how to eliminate the indent (i.e., space before "RULE #"). –  Lijie Xu Feb 18 '13 at 7:27
    
Oh, I know, just use \noindent before "\normalfont RULE~\therules.\quad\itshape\ignorespaces" –  Lijie Xu Feb 18 '13 at 7:33

There's \newtheorem which, with the help of amsthm can be easily customized. This might seem more complicated than defining the environment "by hand", but it better ensures uniformity between the various parts of a document; \topsep is the space LaTeX uses before the list environments, for instance.

\documentclass{article}
\usepackage{lipsum} % for mock text

\usepackage{amsthm}
\newtheoremstyle{rule}
  {\topsep}  % space above
  {\topsep}  % space below
  {\itshape} % body font
  {}         % indent amount (empty = no indent)
  {}         % theorem head font (empty = normal font)
  {.}        % punctuation after theorem head
  { }        % space after theorem head
  {}         % theorem head spec (empty = normal)

\theoremstyle{rule}
\newtheorem{RULE}{RULE}

\begin{document}
\lipsum[1]

\begin{RULE}\label{periscope}
\lipsum[2]
\end{RULE}

Here's the number:~\ref{periscope}. \lipsum[3]

\end{document}

All \newtheorem declarations after \theoremstyle{rule} will inherit the same parameters defined in the style. The predefined styles are plain, definition (upright body font) and remark, but one can build new ones as shown.

enter image description here

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.