Math & Sciencenewenvironment - \boxed problem

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
domi505
Posts: 3
Joined: Sat Mar 20, 2010 12:14 pm

newenvironment - \boxed problem

Post by domi505 »

Hi,

Code: Select all

\newenvironment{test}{\gather\boxed}{\endgather}
It does not border the full argument only the first letter ...

example:

Code: Select all

\documentclass[a4paper]{article}
\usepackage{amsmath}
\newenvironment{test}{\gather\boxed}{\endgather}

\begin{document}
\begin{test}
    123
\end{test}
\end{document}

Any advice?

Thanks a lot,
domi

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

newenvironment - \boxed problem

Post by localghost »

To me it's not really clear what you are aiming at. So I guess that the empheq package from the mh bundle could be helpful.


Best regards
Thorsten
domi505
Posts: 3
Joined: Sat Mar 20, 2010 12:14 pm

newenvironment - \boxed problem

Post by domi505 »

Sorry that I wasn' clear enough.
I try to get a less command. So I want only to enter

Code: Select all

\documentclass[a4paper]{article}
\usepackage{amsmath}
\newenvironment{test}{\gather\boxed}{\endgather}

\begin{document}
\begin{test}
    123
\end{test}
\end{document}
to get this result

Code: Select all

\documentclass[a4paper]{article}
\usepackage{amsmath}

\begin{document}
\begin{gather}
    \boxed{123}
\end{gather}
\end{document}
I dont know what's wrong with the newenvironment command...

thanks
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

newenvironment - \boxed problem

Post by gmedina »

Hi domi505,

\boxed requires curly braces to enclose its argument; otherwise, it will only affect the first character after the command. However, if you try to do something like

Code: Select all

\documentclass[a4paper]{article}
\usepackage{amsmath}

\newenvironment{test}
  {\gather\boxed{}
  {}\endgather}

\begin{document}

\begin{test}
    123
\end{test}

\end{document}
then you will obviously get errors during compilation (due to the unbalanced braces in the arguments of \newenvironment). Some days ago, a similar problem was posed in this thread:

Use unbalanced brackets in /newenvironment (sic).

Take a look at phi's response.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

newenvironment - \boxed problem

Post by localghost »

Post Reply