Add Math Support: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(32 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= Add Math Support =
= Add Math Support =
[[Add Math Support/Abstract|Abstract]] is available too.
== Rationale ==
I have often wanted to have a tool that allows complicated layouts but still is easy to use. This is exactly what Scribus does. However for scientific papers it lacks one main capability: Formulas. So I want to add these as my summer of code project.
The bug tracker also lists requests for math support
* [http://bugs.scribus.net/view.php?id=128 TeX Rendering]
* [http://bugs.scribus.net/view.php?id=1030 Math support]
there's a feature request in the Debian database
* [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=270618#270618 scribus: what about equations?]
and it's also on the
* [[1.3.x_Roadmap|Roadmap]].
So quite a lot of people seem to want this feature.
== Overview ==
In IRC we came to the conclusion that it probably is the best to use a approach like [http://www.bluesky.com/mathsetter/index.html MathSetter].
* Let the user enter LaTeX source (perhaps using LyX's editor)
* Run LaTeX
* Read LaTeX's output
* Display this output instead of the source.
== Details ==
=== Implementation ===
I'll try to create this as a C++-Plugin. If core changes are required I'll restrict the to the minimum level required. As much of the new functionality as possible will be exposed to the Python interface.
=== Image frame vs. group of vectors ===
I was told that image frames are easier to handle internally than groups of vectors and consume less memory. However vectors offer more flexibility (see example below). A good solution for this problem: Use image frames and provide a "Convert to Outlines" as it is done for text frames. The ability to edit the formula's contents is lost, however it's the same with text-frames.
=== Objects ===
The parent object for my addition will be [http://docs.scribus.net/devel/classPageItem__ImageFrame.html PageItem_ImageFrame], i.e. normal ImageFrames. A property that stores the LaTeX source and functions to process the LaTeX source will be added. For editing either a simple text dialog (perhaps with syntax highlighting) is displayed or LyX is started with the existing text loaded as the default file.
=== Processing the LaTeX input ===
When the user has finished editing, LaTeX is run with a temporary file created by inserting the user's input to the template (see below). preview.sty is used to create a DVI file with a matching bounding box. The DVI is converted to either PDF or EPS and then imported (functions for import are already included in Scribus).
=== Handling missing LaTeX / wrong syntax ===
When LaTeX is missing the display of the object is replaced by the error message (or the source?) and a problem is flagged in the preflight verifier.
=== Template ===
There should be a template so the user only has to type the formula and no header. However it is probably a good idea to allow disabling/replacing the template (or at lest the non-required (preview.sty) parts) so the user can define own styles.
=== Helping the user ===
I plan to make things as comfortable to the users as possible, e.g. selecting a font, colors, sizes, etc. via a GUI (either via a modified LyX or with the editor directly embedded)
== Use cases ==
* Scientific posters
It is very hard (if not impossible) to create good-looking posters with LaTeX but it's easy to add formulas to LaTeX documents. On the other hand it's very easy to create good posters with Scribus, but a complicated process is necessary to add just a single formula. The ability to use LaTeX for typesetting the formula and then post-processing it in Scribus (easily possible, after all it's just a vector graphic from Scribus' point of view) would greatly simplify this.
* Math/Physics teachers
At school, I've seen a lot of teachers who created their tests with Microsoft Word and relied on its formula editor or even on basic text formatting (sub-/superscript). They added any "complicated" math symbols (vectors, integrals, etc.) by hand to the printout. Obviously the full power of LaTeX is something they are unwilling to learn (and it is probably not required for them). So I believe they would be happy to have a WYSIWYG tool that supports embedded formulas.
* There a many more use cases and I think virtually anybody involved in natural sciences will at some point be disappointed by his existing software (Word or Latex) because it is hard to get the wanted layout. Then they might look for alternatives...
... and find Scribus! So this will attract new users to Scribus and (perhaps) open source in general.
=== Examples ===
* [http://r2d2.stefanm.com/physik_formeln.pdf Physics formulary]
* [http://r2d2.stefanm.com/Einstein.pdf A sample showing that vectors are also useful]
== Related ==
* The barcode generator works similar to this, but has a major drawback: It's not possible to edit it once a barcode is placed.
* Various LaTeX to HTML tools might be a good starting point to check how the EPS/PDF is best created.
== Deliverables ==
* A plugin (or if that doesn't work a patch) that adds frames, that run LaTeX to get their content.
* Patch to add configuration options for LaTeX path.
* Python bindings (compatible at least with version 2.4 and 2.5)
* One or more LaTeX templates.
* Documentation
=== Spinoffs ===
(Nice things that might be possible but are not guaranteed to work)
This should also be usable to import editable graphs generated in LaTeX (pstricks) and even would provide some support for (LaTeX-style) tables. Formating the table text is however restricted to LaTeX's capabilities and editing has to be done in LaTeX-syntax.
== Timeline ==
* Total time available: 4 month
* Time allocated for coding in the official timeline: 3 month
* Time I'll be not available because I have to learn for tests: about 2 weeks (don't know the dates yet)
* I think there is enough time to do this job in time and also to cope with unforeseen events.
=== Detailed timeline ===
See [[GSoC 2007 Math Plugin Progress]]
'''(bold is from Google's timeline)'''
* ''DONE'' '''April 11: List of accepted student applications published on code.google.com (Interim Period: Students learn more about their project communities)'''
* ''DONE'' I make myself familiar with Scribus' and LyX's code. I also start coding but don't expect too much useful stuff first. Trying different approaches where they make sense and discuss this with the community.
* ''CURRENT'' '''May 28: Students begin coding for their GSoC projects; Google begins issuing initial student payments'''
* Now I add the main functionality to Scribus and start playing with the GUI.
* '''July 9-July 16: Students take midterm surveys; mentors begin mid-term evaluations'''
* Code for running LaTeX and displaying the results should be ready now.
* Main focus during July will be the GUI.
* In August I'll focus on Python bindings and come up with a usable LaTeX template. I'll be quite familiar with Scribus' code so this shouldn't take too long.
* Afterwards I'll write documentation (most documentation will already be done while writing the corresponding code)
* '''August 20: Students upload code to code.google.com/hosting; mentors begin final evaluations; students begin final program evaluations'''
* '''August 31: Final evaluation deadline; Google begins issuing student and mentoring organization payments'''
== Links ==
* [http://bugs.scribus.net/view.php?id=128 TeX Rendering] (Discussion)
* [http://klatexformula.sourceforge.net KLatexFormula] A standalone formula editor for KDE that provides the features required in Scribus
* [http://bugs.scribus.net/view.php?id=1030 Math support] (Discussion)
* [http://www.koffice.org/kformula/ KFormula] (Formula editor, output does not look satisfying)
* [http://www.texmacs.org TeXmacs] (very good looking formula editor, not based on TeX or Emacs despite its name)
* [http://www.lyx.org LyX] (WYSIWYG LaTeX editor)
* [http://home.comcast.net/~jbiddier/sklatex/ sklatex], a LaTeX plugin for [http://www.skencil.org/ skencil]. Definitely worth a look!
* [http://www.2pi.info/latex/sketchlatex/ SketchLaTex], another LaTeX plugin for skencil. Please investigate before re-inventing the wheel!
* [http://cerbo.thphy.uni-duesseldorf.de/~ferber/sketch/ Tex Text], a third LaTeX plugin for skencil.
* [http://wiki.scribus.net/index.php/SoC2007_ideas#Latex_Text_Frames Latex Text Frames] Related idea from the projects list.
* [http://www.kono.cis.iwate-u.ac.jp/~arakit/inkscape/inklatex.html Inklatex] Latex-Plugin for Inkscape
* [http://www.gnomefiles.org/app.php/eqe eqe] a LaTeX formular editor for GNOME
* [http://www.mathtran.org/ mathtran] Online latex to image translator.

Latest revision as of 05:11, 23 July 2012

Add Math Support

Abstract is available too.

Rationale

I have often wanted to have a tool that allows complicated layouts but still is easy to use. This is exactly what Scribus does. However for scientific papers it lacks one main capability: Formulas. So I want to add these as my summer of code project. The bug tracker also lists requests for math support

there's a feature request in the Debian database

and it's also on the

So quite a lot of people seem to want this feature.

Overview

In IRC we came to the conclusion that it probably is the best to use a approach like MathSetter.

  • Let the user enter LaTeX source (perhaps using LyX's editor)
  • Run LaTeX
  • Read LaTeX's output
  • Display this output instead of the source.

Details

Implementation

I'll try to create this as a C++-Plugin. If core changes are required I'll restrict the to the minimum level required. As much of the new functionality as possible will be exposed to the Python interface.

Image frame vs. group of vectors

I was told that image frames are easier to handle internally than groups of vectors and consume less memory. However vectors offer more flexibility (see example below). A good solution for this problem: Use image frames and provide a "Convert to Outlines" as it is done for text frames. The ability to edit the formula's contents is lost, however it's the same with text-frames.

Objects

The parent object for my addition will be PageItem_ImageFrame, i.e. normal ImageFrames. A property that stores the LaTeX source and functions to process the LaTeX source will be added. For editing either a simple text dialog (perhaps with syntax highlighting) is displayed or LyX is started with the existing text loaded as the default file.


Processing the LaTeX input

When the user has finished editing, LaTeX is run with a temporary file created by inserting the user's input to the template (see below). preview.sty is used to create a DVI file with a matching bounding box. The DVI is converted to either PDF or EPS and then imported (functions for import are already included in Scribus).

Handling missing LaTeX / wrong syntax

When LaTeX is missing the display of the object is replaced by the error message (or the source?) and a problem is flagged in the preflight verifier.

Template

There should be a template so the user only has to type the formula and no header. However it is probably a good idea to allow disabling/replacing the template (or at lest the non-required (preview.sty) parts) so the user can define own styles.

Helping the user

I plan to make things as comfortable to the users as possible, e.g. selecting a font, colors, sizes, etc. via a GUI (either via a modified LyX or with the editor directly embedded)

Use cases

  • Scientific posters

It is very hard (if not impossible) to create good-looking posters with LaTeX but it's easy to add formulas to LaTeX documents. On the other hand it's very easy to create good posters with Scribus, but a complicated process is necessary to add just a single formula. The ability to use LaTeX for typesetting the formula and then post-processing it in Scribus (easily possible, after all it's just a vector graphic from Scribus' point of view) would greatly simplify this.

  • Math/Physics teachers

At school, I've seen a lot of teachers who created their tests with Microsoft Word and relied on its formula editor or even on basic text formatting (sub-/superscript). They added any "complicated" math symbols (vectors, integrals, etc.) by hand to the printout. Obviously the full power of LaTeX is something they are unwilling to learn (and it is probably not required for them). So I believe they would be happy to have a WYSIWYG tool that supports embedded formulas.

  • There a many more use cases and I think virtually anybody involved in natural sciences will at some point be disappointed by his existing software (Word or Latex) because it is hard to get the wanted layout. Then they might look for alternatives...

... and find Scribus! So this will attract new users to Scribus and (perhaps) open source in general.

Examples

Related

  • The barcode generator works similar to this, but has a major drawback: It's not possible to edit it once a barcode is placed.
  • Various LaTeX to HTML tools might be a good starting point to check how the EPS/PDF is best created.

Deliverables

  • A plugin (or if that doesn't work a patch) that adds frames, that run LaTeX to get their content.
  • Patch to add configuration options for LaTeX path.
  • Python bindings (compatible at least with version 2.4 and 2.5)
  • One or more LaTeX templates.
  • Documentation

Spinoffs

(Nice things that might be possible but are not guaranteed to work)

This should also be usable to import editable graphs generated in LaTeX (pstricks) and even would provide some support for (LaTeX-style) tables. Formating the table text is however restricted to LaTeX's capabilities and editing has to be done in LaTeX-syntax.

Timeline

  • Total time available: 4 month
  • Time allocated for coding in the official timeline: 3 month
  • Time I'll be not available because I have to learn for tests: about 2 weeks (don't know the dates yet)
  • I think there is enough time to do this job in time and also to cope with unforeseen events.

Detailed timeline

See GSoC 2007 Math Plugin Progress

(bold is from Google's timeline)

  • DONE April 11: List of accepted student applications published on code.google.com (Interim Period: Students learn more about their project communities)
  • DONE I make myself familiar with Scribus' and LyX's code. I also start coding but don't expect too much useful stuff first. Trying different approaches where they make sense and discuss this with the community.
  • CURRENT May 28: Students begin coding for their GSoC projects; Google begins issuing initial student payments
  • Now I add the main functionality to Scribus and start playing with the GUI.
  • July 9-July 16: Students take midterm surveys; mentors begin mid-term evaluations
  • Code for running LaTeX and displaying the results should be ready now.
  • Main focus during July will be the GUI.
  • In August I'll focus on Python bindings and come up with a usable LaTeX template. I'll be quite familiar with Scribus' code so this shouldn't take too long.
  • Afterwards I'll write documentation (most documentation will already be done while writing the corresponding code)
  • August 20: Students upload code to code.google.com/hosting; mentors begin final evaluations; students begin final program evaluations
  • August 31: Final evaluation deadline; Google begins issuing student and mentoring organization payments

Links

  • TeX Rendering (Discussion)
  • KLatexFormula A standalone formula editor for KDE that provides the features required in Scribus
  • Math support (Discussion)
  • KFormula (Formula editor, output does not look satisfying)
  • TeXmacs (very good looking formula editor, not based on TeX or Emacs despite its name)
  • LyX (WYSIWYG LaTeX editor)
  • sklatex, a LaTeX plugin for skencil. Definitely worth a look!
  • SketchLaTex, another LaTeX plugin for skencil. Please investigate before re-inventing the wheel!
  • Tex Text, a third LaTeX plugin for skencil.
  • Latex Text Frames Related idea from the projects list.
  • Inklatex Latex-Plugin for Inkscape
  • eqe a LaTeX formular editor for GNOME
  • mathtran Online latex to image translator.