On Monday 14 October 2002 3:26 pm, Angus Leeming wrote: > I played some more with this. It transpires that fleqn does > not, after all, enable me to position the preview in the same > place on the LyX screen as the editable view. LaTeX still > retains the concept of a page width and all that happens is > that the equation is positioned differently within this width. > Ie, we end up with an enormous right hand margin ;-) > > An alternative to this "fix" might be to use > $ \displaystyle ... $ > when outputting \[ ... \] equations. I attach the two snippets > generated from the test file below. To my eyes, snippet2.png > is exactly what we're looking for here (and it would be > trivial to create such output). > > What do you lot, the pseudo-users think?
Thanks for the feedback :-) Attached is a small lyx file together with a small patch that does as I suggested above. Try out the previews with and without this patch. Does the patch not make it easier to navigate the document? What do the powers that be think of applying this patch? Regards, Angus
#LyX 1.3 created this file. For more info see http://www.lyx.org/ \lyxformat 221 \textclass article \language english \inputencoding auto \fontscheme default \graphics default \paperfontsize default \papersize Default \paperpackage a4 \use_geometry 0 \use_amsmath 0 \use_natbib 0 \use_numerical_citations 0 \paperorientation portrait \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language english \quotes_times 2 \papercolumns 1 \papersides 1 \paperpagestyle default \layout Standard An equation in display mode \begin_inset Formula \[ E=\int_{A}\!\!\mathrm{d}A\:\rho^{2}\] \end_inset and something \begin_inset Formula $D$ \end_inset in text mode. \the_end
Index: src/mathed/formula.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formula.C,v retrieving revision 1.240 diff -u -p -r1.240 formula.C --- src/mathed/formula.C 27 Aug 2002 10:14:56 -0000 1.240 +++ src/mathed/formula.C 17 Oct 2002 14:10:06 -0000 @@ -330,5 +330,20 @@ string const InsetFormula::PreviewImpl:: ostringstream ls; WriteStream wi(ls, false, false); parent().par_->write(wi); - return ls.str().c_str(); + string str = ls.str().c_str(); + + // If we are in displaymode, the preview will include the margins + // on either side of the previewed equation. + // We can create an image with a tight bounding box by replacing the + // "\[ ... \]" delimiters with "$ \displaystyle ... $". + // Note that we have to get rid of any trailing '\n's for the fix + // to work. + if (prefixIs(str, "\\[")) { + std::cerr << "before\n" << str << std::endl; + str = rtrim(rtrim(ltrim(str, "\\["), "\n"), "\\]"); + str = "$ \\displaystyle " + str + " $"; + std::cerr << "after\n" << str << std::endl; + } + + return str; }