The graphicx
package provides a scalebox
command. I'd like to encapsulate it in an environment like that:
\newenvironment{scaleb}{ \scalebox{0.7}{ } {}}
However, the second example below works, but the first one outputs the text without scaling and destroys all my layout.
\begin{scaleb}test\end{scaleb}
\scalebox{0.7}{test}
What am I doing wrong ?
You are trying to have unmatched { and } and the begin and end part of the environment, which TeX won't let you do. Your \newenvironment is read as follows by LaTeX:
\newenvironment{scaleb}{ \scalebox{0.7}{} {} }
so you have an empty \scalebox and no endscaleb-part. Accessing the content of an environment is slightly tricky and depends on your circumstances (can your scaleb environments be nested, do you want to be able to build new environments on top of scaleb so that you don't have a literal "\end{scaleb}" in your document, etc.) Maybe the environ package can help you: http://www.ctan.org/tex-archive/macros/latex/contrib/environ/.