1999-09-27 18:44:28 +00:00
|
|
|
/*
|
|
|
|
* File: math_write.h
|
|
|
|
* Purpose: Write math paragraphs in LaTeX
|
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
|
|
|
* Created: January 1996
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Dependencies: Xlib, XForms
|
|
|
|
*
|
|
|
|
* Copyright: (c) 1996, 1997 Alejandro Aguilar Sierra
|
|
|
|
*
|
|
|
|
* Version: 0.8beta, Mathed & Lyx project.
|
|
|
|
*
|
|
|
|
* You are free to use and modify this code under the terms of
|
|
|
|
* the GNU General Public Licence version 2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2000-01-06 02:44:26 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LString.h"
|
|
|
|
#include "math_inset.h"
|
|
|
|
#include "math_iter.h"
|
|
|
|
#include "math_parser.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/lstrings.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
extern char const * latex_mathenv[];
|
|
|
|
extern char * latex_mathspace[];
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// quite a hack i know. Should be done with return values...
|
|
|
|
static int number_of_newlines;
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
char const * math_font_name[] = {
|
1999-09-27 18:44:28 +00:00
|
|
|
"mathrm",
|
|
|
|
"mathcal",
|
|
|
|
"mathbf",
|
|
|
|
"mathsf",
|
|
|
|
"mathtt",
|
|
|
|
"mathit",
|
|
|
|
"textrm"
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
1999-12-07 00:44:53 +00:00
|
|
|
MathSpaceInset::Write(ostream & os)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 11:06:41 +00:00
|
|
|
if (space >= 0 && space < 6) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-09-27 18:44:28 +00:00
|
|
|
MathSpaceInset::Write(output);
|
1999-12-07 00:44:53 +00:00
|
|
|
os << output;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void
|
1999-11-15 11:06:41 +00:00
|
|
|
MathSpaceInset::Write(string & outf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 11:06:41 +00:00
|
|
|
if (space >= 0 && space < 6) {
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '\\';
|
|
|
|
outf += latex_mathspace[space];
|
|
|
|
outf += ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
1999-12-07 00:44:53 +00:00
|
|
|
MathDotsInset::Write(ostream & os)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-09-27 18:44:28 +00:00
|
|
|
MathDotsInset::Write(output);
|
1999-12-07 00:44:53 +00:00
|
|
|
os << output;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
void
|
1999-11-15 11:06:41 +00:00
|
|
|
MathDotsInset::Write(string & outf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
outf += '\\';
|
|
|
|
outf += name;
|
|
|
|
outf += ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
void MathSqrtInset::Write(ostream & os)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-12-07 00:44:53 +00:00
|
|
|
MathSqrtInset::Write(output);
|
|
|
|
os << output;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
void MathSqrtInset::Write(string & outf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
outf += '\\';
|
|
|
|
outf += name;
|
|
|
|
outf += '{';
|
|
|
|
MathParInset::Write(outf);
|
|
|
|
outf += '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
void MathDelimInset::Write(ostream & os)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-09-27 18:44:28 +00:00
|
|
|
MathDelimInset::Write(output);
|
1999-12-07 00:44:53 +00:00
|
|
|
os << output;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
void MathDelimInset::Write(string & outf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 11:06:41 +00:00
|
|
|
latexkeys * l = (left != '|') ? lm_get_key_by_id(left, LM_TK_SYM): 0;
|
|
|
|
latexkeys * r = (right != '|') ? lm_get_key_by_id(right, LM_TK_SYM): 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += "\\left";
|
|
|
|
if (l) {
|
|
|
|
outf += '\\';
|
|
|
|
outf += l->name;
|
|
|
|
outf += ' ';
|
|
|
|
} else {
|
1999-11-15 11:06:41 +00:00
|
|
|
if (left == '{' || left == '}') {
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '\\';
|
1999-12-13 00:05:34 +00:00
|
|
|
outf += char(left);
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += ' ';
|
|
|
|
} else {
|
1999-12-13 00:05:34 +00:00
|
|
|
outf += char(left);
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MathParInset::Write(outf);
|
|
|
|
outf += "\\right";
|
|
|
|
if (r) {
|
|
|
|
outf += '\\';
|
|
|
|
outf += r->name;
|
|
|
|
outf += ' ';
|
|
|
|
} else {
|
1999-11-15 11:06:41 +00:00
|
|
|
if (right == '{' || right == '}') {
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '\\';
|
1999-12-13 00:05:34 +00:00
|
|
|
outf += char(right);
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += ' ';
|
|
|
|
} else {
|
1999-12-13 00:05:34 +00:00
|
|
|
outf += char(right);
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
void MathDecorationInset::Write(ostream & os)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-09-27 18:44:28 +00:00
|
|
|
MathDecorationInset::Write(output);
|
1999-12-07 00:44:53 +00:00
|
|
|
os << output;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
void MathDecorationInset::Write(string & outf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 11:06:41 +00:00
|
|
|
latexkeys * l = lm_get_key_by_id(deco, LM_TK_WIDE);
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '\\';
|
|
|
|
outf += l->name;
|
|
|
|
outf += '{';
|
|
|
|
MathParInset::Write(outf);
|
|
|
|
outf += '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
void MathAccentInset::Write(ostream & os)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-09-27 18:44:28 +00:00
|
|
|
MathAccentInset::Write(output);
|
1999-12-07 00:44:53 +00:00
|
|
|
os << output;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
void MathAccentInset::Write(string & outf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 11:06:41 +00:00
|
|
|
latexkeys * l = lm_get_key_by_id(code, LM_TK_ACCENT);
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '\\';
|
|
|
|
outf += l->name;
|
1999-11-15 11:06:41 +00:00
|
|
|
if (code!= LM_not)
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '{';
|
|
|
|
else
|
|
|
|
outf += ' ';
|
|
|
|
|
|
|
|
if (inset) {
|
|
|
|
inset->Write(outf);
|
|
|
|
} else {
|
1999-11-15 11:06:41 +00:00
|
|
|
if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM) {
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '\\';
|
|
|
|
outf += math_font_name[fn-LM_TC_RM];
|
|
|
|
outf += '{';
|
|
|
|
}
|
|
|
|
if (MathIsSymbol(fn)) {
|
|
|
|
latexkeys *l = lm_get_key_by_id(c, LM_TK_SYM);
|
|
|
|
if (l) {
|
|
|
|
outf += '\\';
|
|
|
|
outf += l->name;
|
|
|
|
outf += ' ';
|
|
|
|
}
|
|
|
|
} else
|
1999-12-13 00:05:34 +00:00
|
|
|
outf += char(c);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM)
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '}';
|
|
|
|
}
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
if (code!= LM_not)
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
void MathBigopInset::Write(ostream & os)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-09-27 18:44:28 +00:00
|
|
|
MathBigopInset::Write(output);
|
1999-12-07 00:44:53 +00:00
|
|
|
os << output;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
void MathBigopInset::Write(string & outf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
bool limp = GetLimits();
|
|
|
|
|
|
|
|
outf += '\\';
|
|
|
|
outf += name;
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
if (limp && !(sym!= LM_int && sym!= LM_oint && (GetStyle() == LM_ST_DISPLAY)))
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += "\\limits ";
|
|
|
|
else
|
1999-11-15 11:06:41 +00:00
|
|
|
if (!limp && (sym!= LM_int && sym!= LM_oint && (GetStyle() == LM_ST_DISPLAY)))
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += "\\nolimits ";
|
|
|
|
else
|
|
|
|
outf += ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
void MathFracInset::Write(ostream & os)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-12-07 00:44:53 +00:00
|
|
|
MathFracInset::Write(output);
|
|
|
|
os << output;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
void MathFracInset::Write(string & outf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
outf += '\\';
|
|
|
|
outf += name;
|
|
|
|
outf += '{';
|
|
|
|
MathParInset::Write(outf);
|
|
|
|
outf += "}{";
|
|
|
|
den->Write(outf);
|
|
|
|
outf += '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
void MathParInset::Write(ostream & os)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!array) return;
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-09-27 18:44:28 +00:00
|
|
|
MathParInset::Write(output);
|
1999-12-07 00:44:53 +00:00
|
|
|
os << output;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
void MathParInset::Write(string & outf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!array) return;
|
|
|
|
int brace = 0;
|
1999-11-15 11:06:41 +00:00
|
|
|
latexkeys * l;
|
1999-09-27 18:44:28 +00:00
|
|
|
MathedIter data(array);
|
|
|
|
// hack
|
1999-11-15 11:06:41 +00:00
|
|
|
MathedRowSt const * crow = getRowSt();
|
1999-09-27 18:44:28 +00:00
|
|
|
data.Reset();
|
|
|
|
|
|
|
|
if (!Permit(LMPF_FIXED_SIZE)) {
|
|
|
|
l = lm_get_key_by_id(size, LM_TK_STY);
|
|
|
|
if (l) {
|
|
|
|
outf += '\\';
|
|
|
|
outf += l->name;
|
|
|
|
outf += ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (data.OK()) {
|
|
|
|
byte cx = data.GetChar();
|
1999-11-15 11:06:41 +00:00
|
|
|
if (cx>= ' ') {
|
1999-09-27 18:44:28 +00:00
|
|
|
int ls;
|
1999-11-15 11:06:41 +00:00
|
|
|
byte * s = data.GetString(ls);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
if (data.FCode()>= LM_TC_RM && data.FCode()<= LM_TC_TEXTRM) {
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '\\';
|
|
|
|
outf += math_font_name[data.FCode()-LM_TC_RM];
|
|
|
|
outf += '{';
|
|
|
|
}
|
|
|
|
while (ls>0) {
|
|
|
|
if (MathIsSymbol(data.FCode())) {
|
1999-11-15 11:06:41 +00:00
|
|
|
l = lm_get_key_by_id(*s,(data.FCode() == LM_TC_BSYM)?LM_TK_BIGSYM:LM_TK_SYM);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (l) {
|
|
|
|
outf += '\\';
|
|
|
|
outf += l->name;
|
|
|
|
outf += ' ';
|
|
|
|
} else {
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr << "Illegal symbol code[" << *s
|
|
|
|
<< " " << ls << " " << data.FCode() << "]";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Is there a standard logical XOR?
|
1999-11-15 11:06:41 +00:00
|
|
|
if ((data.FCode() == LM_TC_TEX && *s!= '{' && *s!= '}') ||
|
|
|
|
(data.FCode() == LM_TC_SPECIAL))
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '\\';
|
|
|
|
else {
|
2000-01-24 18:34:46 +00:00
|
|
|
if (*s == '{') ++brace;
|
|
|
|
if (*s == '}') --brace;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 11:06:41 +00:00
|
|
|
if (*s == '}' && data.FCode() == LM_TC_TEX && brace<0)
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr <<"Math warning: Unexpected closing brace."
|
|
|
|
<< endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
1999-12-13 00:05:34 +00:00
|
|
|
outf += char(*s);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-01-24 18:34:46 +00:00
|
|
|
++s; --ls;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 11:06:41 +00:00
|
|
|
if (data.FCode()>= LM_TC_RM && data.FCode()<= LM_TC_TEXTRM)
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '}';
|
|
|
|
} else
|
|
|
|
if (MathIsInset(cx)) {
|
|
|
|
MathedInset *p = data.GetInset();
|
1999-11-15 11:06:41 +00:00
|
|
|
if (cx == LM_TC_UP)
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += "^{";
|
1999-11-15 11:06:41 +00:00
|
|
|
if (cx == LM_TC_DOWN)
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += "_{";
|
|
|
|
p->Write(outf);
|
1999-11-15 11:06:41 +00:00
|
|
|
if (cx == LM_TC_UP || cx == LM_TC_DOWN)
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '}';
|
|
|
|
data.Next();
|
|
|
|
} else
|
|
|
|
switch(cx) {
|
|
|
|
case LM_TC_TAB:
|
|
|
|
{
|
|
|
|
outf += " & ";
|
|
|
|
data.Next();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LM_TC_CR:
|
|
|
|
{
|
|
|
|
if (crow) {
|
|
|
|
if (!crow->isNumbered()) {
|
1999-11-15 11:06:41 +00:00
|
|
|
outf += "\\nonumber ";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
if (crow->getLabel()) {
|
|
|
|
outf += "\\label{";
|
|
|
|
outf += crow->getLabel();
|
|
|
|
outf += "} ";
|
|
|
|
}
|
|
|
|
crow = crow->getNext();
|
|
|
|
}
|
|
|
|
outf += "\\\\\n";
|
2000-01-24 18:34:46 +00:00
|
|
|
++number_of_newlines;
|
1999-09-27 18:44:28 +00:00
|
|
|
data.Next();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr << "WMath Error: unrecognized code[" << cx << "]";
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (crow) {
|
|
|
|
if (!crow->isNumbered()) {
|
1999-11-15 11:06:41 +00:00
|
|
|
outf += "\\nonumber ";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
if (crow->getLabel()) {
|
|
|
|
outf += "\\label{";
|
|
|
|
outf += crow->getLabel();
|
|
|
|
outf += "} ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (brace>0) {
|
|
|
|
outf += '}';
|
2000-01-24 18:34:46 +00:00
|
|
|
--brace;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
void MathMatrixInset::Write(ostream & os)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-09-27 18:44:28 +00:00
|
|
|
MathMatrixInset::Write(output);
|
1999-12-07 00:44:53 +00:00
|
|
|
os << output;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
|
|
|
void MathMatrixInset::Write(string & outf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (GetType() == LM_OT_MATRIX){
|
|
|
|
outf += "\\begin{";
|
|
|
|
outf += name;
|
|
|
|
outf += '}';
|
1999-11-15 11:06:41 +00:00
|
|
|
if (v_align == 't' || v_align == 'b') {
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += '[';
|
1999-12-13 00:05:34 +00:00
|
|
|
outf += char(v_align);
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += ']';
|
|
|
|
}
|
|
|
|
outf += '{';
|
|
|
|
outf += h_align;
|
|
|
|
outf += "}\n";
|
2000-01-24 18:34:46 +00:00
|
|
|
++number_of_newlines;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
MathParInset::Write(outf);
|
|
|
|
if (GetType() == LM_OT_MATRIX){
|
|
|
|
outf += "\n\\end{";
|
|
|
|
outf += name;
|
|
|
|
outf += '}';
|
2000-01-24 18:34:46 +00:00
|
|
|
++number_of_newlines;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
void mathed_write(MathParInset * p, ostream & os, int * newlines,
|
|
|
|
char fragile, char const * label)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string output;
|
1999-09-27 18:44:28 +00:00
|
|
|
mathed_write(p, output, newlines, fragile, label);
|
1999-12-07 00:44:53 +00:00
|
|
|
os << output;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
extern int tex_code_break_column;
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
void mathed_write(MathParInset * p, string & outf, int * newlines,
|
|
|
|
char fragile, char const * label)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
number_of_newlines = 0;
|
|
|
|
short mathed_env = p->GetType();
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
if (mathed_env == LM_EN_INTEXT) {
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fragile) outf += "\\protect";
|
|
|
|
outf += "\\( "; // changed from " \\( " (Albrecht Dress)
|
|
|
|
}
|
|
|
|
else {
|
1999-10-02 16:21:10 +00:00
|
|
|
if (!suffixIs(outf, '\n')) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// in batchmode we need to make sure
|
|
|
|
// a space before an equation doesn't
|
|
|
|
// make the LaTeX output different
|
|
|
|
// compared to "Exported LaTeX" ARRae
|
|
|
|
// Modified to work in a cleaner and hopefully more general way
|
|
|
|
// (JMarc)
|
|
|
|
outf += "\n";
|
2000-01-24 18:34:46 +00:00
|
|
|
++number_of_newlines;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 11:06:41 +00:00
|
|
|
if (mathed_env == LM_EN_DISPLAY){
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += "\\[\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
outf += "\\begin{";
|
|
|
|
outf += latex_mathenv[mathed_env];
|
|
|
|
outf += "}\n";
|
|
|
|
}
|
2000-01-24 18:34:46 +00:00
|
|
|
++number_of_newlines;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
if (label && label[0]>' ' && mathed_env == LM_EN_EQUATION){
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += "\\label{";
|
|
|
|
outf += label;
|
|
|
|
outf += "}\n";
|
2000-01-24 18:34:46 +00:00
|
|
|
++number_of_newlines;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
p->Write(outf);
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
if (mathed_env == LM_EN_INTEXT){
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fragile) outf += "\\protect";
|
|
|
|
outf += " \\)";
|
|
|
|
}
|
1999-11-15 11:06:41 +00:00
|
|
|
else if (mathed_env == LM_EN_DISPLAY){
|
1999-09-27 18:44:28 +00:00
|
|
|
outf += "\\]\n";
|
2000-01-24 18:34:46 +00:00
|
|
|
++number_of_newlines;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
outf += "\n\\end{";
|
|
|
|
outf += latex_mathenv[mathed_env];
|
|
|
|
outf += "}\n";
|
2000-01-24 18:34:46 +00:00
|
|
|
number_of_newlines += 2;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
*newlines = number_of_newlines;
|
|
|
|
}
|