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.

How can I change the style of an element in LaTeX ?

I would like to do some basic modifications on some environments. For example changing the text size in quotation, margins in verbatim or the line spacing in itemize blocks.

I want the change to be made on every block of the document.

How can I rewrite some style definitions ?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Typically you can write your own environment that wraps around the one you want to change. For example

\newenvironment{quotingalt}
  {% \begin{quotingalt}
   \large% Change font size
   \begin{quote}%
  }{% \end{quotingalt}
   \end{quote}%
  }

In fact, this is how many of the default environments in the standard classes are written. For example, consider the quote environment from article.cls:

\newenvironment{quote}
               {\list{}{\rightmargin\leftmargin}%
                \item\relax}
               {\endlist}

The above code initiates the list environment with \list and ends it with \endlist to form quote.

Since the environment has some scope, changes are localized so you don't have to worry about resetting them. The environ package allows a more intuitive command-like interface to environments, providing \BODY for the grabbed content inside it:

\usepackage{environ}% http://ctan.org/pkg/environ
\NewEnviron{quotingalt}{%
  \large% Change the font size
  \begin{quote}\BODY\end{quote}%
}

Alternative approaches include keeping the original name and modifying it using a patch (with etoolbox and friends) or a complete redefinition with your style added.

share|improve this answer
    
Thank you, I'll do it that way. I was hoping to be able easily to keep the same name (and not change everything in my doc) but it's ok. –  Martin Trigaux Aug 17 '12 at 10:09
    
@MartinTrigaux: It is possible to keep the same environment name using a patch (as suggested in my answer) or by "replacing" the names. This all depends on the specific environment you're interested in changing (since arguments might play a part in this). If you could provide a description of this environment, more help could be provided. My alternative solution is to wrap the environment with you modifications, which provides a general result. –  Werner Aug 17 '12 at 15:26
add comment

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.