Hi all,
still on the theme "box around an equation", perhaps I found a bug in
Lyx (I am using Lyx 1.3.5 for MAC OSX 10.3.9), but I found also a
workaround.
Yesterday I proposed the following procedure
HOW TO PUT A BOX AROUND AN EQUATION
1) go to math mode with the command INSERT --> MATH --> DISPLAY FORMULA
2) type \fbox (visible box) and then press carriage return or the
spacebar
3) the text "\fbox" disappear and a framed box appears with the cursor
inside
but WARNING, YOU ARE IN TEXT MODE NOW!
4) go again to math mode with the command INSERT --> MATH --> INLINE
FORMULA
5) type the equation there inside
6) eventually apply equation number as usual
Well, it work fine, both within Lyx, and also if you export the file on
a Latex document ... but, if you now quit Lyx and start again, then
something becomes wrong: you get an empty box in front of the equation,
then the equation that was in the box, and then some garbage.
Example: Follow the above procedure to type in Lyx the display equation
x=2 with the frame around. From here Lyx will export the CORRECT latex
\begin{equation}
\fbox{$x=2$}\end{equation}
Now save the lyx file, quit Lyx and start again. You will have the
equation screwed, and the corresponding latex will be (don't ask me
why)
\begin{equation}
\fbox{}x=2\end{equation}
{equation}
Hence it seems that there in an inconsistency in Lyx between writing
and reading its own data file.
(if this is really a bug, could somebody please inform the developers
team?)
WORKAROUND
The problem can be solved nesting an \mbox command inside the framed
box before typing the equation. This seems to prevent Lyx from
inconsistencies in reading the data file. Here is the update procedure
that seems to work:
HOW TO PUT A BOX AROUND AN EQUATION - THE FINAL VERSION?
1) go to math mode with the command INSERT --> MATH --> DISPLAY FORMULA
2) type \fbox (visible box) and then press carriage return or the
spacebar
3) the text "\fbox" disappear and a framed box appears with the cursor
inside
4) type \mbox and then press carriage return or the spacebar
5) the text "\mbox" disappear and a second box appears with the cursor
inside,
but, WARNING, YOU ARE IN TEXT MODE NOW!
6) go again to math mode with the command INSERT --> MATH --> INLINE
FORMULA
7) type the equation there inside
8) eventually apply equation number as usual
In this way if you quit Lyx and start again everything seems to work
I hope this is useful for somebody
Giorgio Zavarise
POST SCRIPTUM
I tried also the above procedure recently proposed by Paul Smith, but
for me it does not work. I means the result looks correct, but I am not
able to pdflatex it, and I got the following error message:
Undefined control sequence.
\boxed
{x=2}\end{equation}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
Perhaps some AMS package is required for it. If this is the case, then
please could somebody specify what has to be added?
Question:
How can I insert a frame around my equation?
1) Go to math mode (inline formula or display formula)
2) Type \boxed and then a press carriage return or the spacebar
3) The text "\boxed" disappears and a framed box appears
4) Type the equation inside the
box