tags:

views:

228

answers:

3

Is it possible to use multiple commands in one environment block in LaTeX? I tried something like this, but it didn't work...

\begin{sffamily,emph}
    I'm sans serif and italic!
\end{sffamily,emph}
A: 

The wording on this help site

LaTeX provides a number of different paragraph-making environments. Each environment begins and ends in the same manner.

 \begin{environment-name}
 ....
 ....
 \end{environment-name}

sounds to me like you can use precisely one environment per begin/end statement.

Mark Rushakoff
+8  A: 

No, but there are two ways to get around that:

1) Define your own environment:

\newenvironment{sfemph}{\begin{sffamily}\begin{emph}}{\end{sffamily}\end{emph}}

\begin{sfemph}your text here\end{sfemph}

2) Use the non-environment forms (though this doesn't work for every command):

{\sffamily\emph your text here}
David Zaslavsky
This answer is absolutely correct, I just wanted to add how multiple arguments work in some commands (not begin but others). For a command that takes multiple required arguments like `\frac{numerator}{denominator}` they come in multiple curly brace blocks. Some take one (and only one) optional argument in square braces before required argument(s) as in `\documentclass[twocolumn]{article}` but as there can only be one optional argument sometimes this will have comma separated values.
Joel
+1  A: 

The syntax does not exist (AFAIK) to begin and end two environments in one statement, as it seems you're trying to do by separating your environment names with a comma. I'm not sure why you'd think this would work, possibly just not being familiar with LaTeX syntax and style. As dlamblin said, why not something like this:

\begin{sffamily}
    \begin{emph}
        I'm sans serif and italic!
    \end{emph}
\end{sffamily}

This is the most general solution. However, if you're trying to just emph and sans serif text, there are other ways to de-serif-ify your font. Have you looked at the invaluable Not-so-short Intro to LaTeX? If not, you should - it gives a really good high-level approach to using and thinking about LaTeX, in addition to plenty of answers to "how-do-I-..." type questions.

Matt Ball