I want to create an environment that puts its content within a minipage as wide as the current page. The environment would work as follows:
\begin{FitToWidth}
HELLO
\end{FitToWidth}
and produce a "HELLO" as wide as the textwidth of the page.
Without defining an environment, this can be done as follows:
\documentclass[letter,11pt]{article}
\usepackage{graphicx}
\begin{document}
\begin{center}
\begin{minipage}{\textwidth}
\begin{center}
\resizebox{\textwidth}{!}{%
HELLO
}
\end{center}
\end{minipage}
\end{center}
\end{document}
The problem is that when I try to turn this code into an environment, LaTeX returns an error (Package graphics Error: Division by 0).
This is what I have unsuccessfully tried:
\newenvironment{FitToWidth}{
\begin{center}
\begin{minipage}{\textwidth}
\begin{center}
\resizebox{\textwidth}{!}{%
} {
}
\end{center}
\end{minipage}
\end{center}
}
What is the problem?


adjustboxrather than reinventing the wheel is a good idea. Thank you! – scaramouche Feb 22 '15 at 15:05