LaTeX forum ⇒ GeneralUse unbalanced brackets in /newenvironment

LaTeX specific issues not fitting into one of the other forums of this category.
Posts: 11
Joined: Tue Sep 15, 2009 3:53 am

Re: Use unbalanced brackets in /newenvironment

Postby kostka » Thu Feb 18, 2010 10:53 pm

Okay, this seems to work perfectly:

  1. \documentclass{minimal}
  3. \usepackage{fancybox}
  5. \newlength{\boxedeqnlen}
  6. \newenvironment{equationbox}{\vspace{1em}\\%
  7. \begin{Sbox}\setlength{\boxedeqnlen}{\linewidth}%
  8. \addtolength{\boxedeqnlen}{-2\fboxsep}%
  9. \addtolength{\boxedeqnlen}{-2\fboxrule}%
  10. \begin{minipage}{\boxedeqnlen}%
  11. \begin{equation}}%
  12. {\end{equation}%
  13. \end{minipage}%
  14. \end{Sbox}\fbox{\TheSbox}\vspace{1em}\\}
  16. \begin{document}
  17. If we find the value of $x$ which solves the equation
  18. \begin{equation}
  19. 2x-1=0
  20. \end{equation}
  21. we obtain
  22. \begin{equationbox}
  23. x=\frac{1}{2}
  24. \end{equationbox}
  25. where we employ the use of a \textit{fraction}.
  27. \end{document}

It behaves exactly like the equation environment as far as I can tell regarding indenting (or not indenting) the next line. It also looks good in both single space and 1.5 spaced environments. Thanks everyone! Back to thesis writing. :geek:

Side note: I couldn't get /bgroup or /egroup to work, but I can't recall the exact problem. They seem to only be substitutes for { and } in certain scenarios.

Side note 2: The main problem with lrbox is that, while it does save text, it also formats it according to the currently activated environment, so if you do something like \begin{equation}\usebox{\thebox}\end{equation}, then the text in \thebox will still be formatted in the normal text mode.


Return to “General”

Who is online

Users browsing this forum: No registered users and 10 guests