Commit c46e5bcf authored by Alexander Semke's avatar Alexander Semke

Use preview package only instead of standalone for the preview of

rendered LaTeX images. standalone LaTeX package that is being used
now doesn't work on openSuse and maybe on some other distributions.

Differential Revision: https://phabricator.kde.org/D25579
parent bc249bae
......@@ -33,21 +33,21 @@
#include "lib/renderer.h"
#include "lib/latexrenderer.h"
static const QLatin1String mathTex("\\documentclass%9{standalone}"\
static const QLatin1String mathTex("\\documentclass%9{minimal}"\
"\\usepackage{amsfonts,amssymb}"\
"\\usepackage{amsmath}"\
"\\usepackage[utf8]{inputenc}"\
"\\usepackage[active,displaymath,textmath,tightpage]{preview}"\
"\\usepackage{color}"\
/*
"\\setlength\\textwidth{5in}"\
"\\setlength{\\parindent}{0pt}"\
"\\pagestyle{empty}"\
*/
"\\begin{document}"\
"\\pagecolor[rgb]{%1,%2,%3}"\
"\\begin{preview}"\
"$"\
"\\colorbox[rgb]{%1,%2,%3}{"\
"\\color[rgb]{%4,%5,%6}"\
"\\fontsize{%7}{%7}\\selectfont"\
"%8"\
"%8}"\
"$"\
"\\end{preview}"
"\\end{document}");
static const QLatin1String eqnHeader("$\\displaystyle %1$");
......@@ -82,23 +82,23 @@ void MathRenderTask::run()
QTemporaryFile texFile(tempDir + QDir::separator() + QLatin1String("cantor_tex-XXXXXX.tex"));
texFile.open();
// Verify that standalone.cls available for rendering and could be founded
if (!tempDir.contains(QLatin1String("standalone.cls")))
// make sure we have preview.sty available
if (!tempDir.contains(QLatin1String("preview.cls")))
{
QString file = QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1String("latex/standalone.cls"));
QString file = QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1String("latex/preview.sty"));
if (file.isEmpty())
file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("cantor/latex/standalone.cls"));
file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("cantor/latex/preview.sty"));
if (file.isEmpty())
{
result->successful = false;
result->errorMessage = QString::fromLatin1("needed for math render standalone.cls file not found in Cantor data directory");
result->errorMessage = QString::fromLatin1("LaTeX style file preview.sty not found.");
finalize(result);
return;
}
else
QFile::copy(file, tempDir + QDir::separator() + QLatin1String("standalone.cls"));
QFile::copy(file, tempDir + QDir::separator() + QLatin1String("preview.sty"));
}
QString expressionTex=mathTex;
......
......@@ -29,4 +29,4 @@ set_target_properties(Discount::Lib PROPERTIES
add_dependencies(Discount::Lib discount_project-build)
# preview.sty
install(FILES standalone.cls DESTINATION ${KDE_INSTALL_DATADIR}/cantor/latex)
install(FILES preview.sty DESTINATION ${KDE_INSTALL_DATADIR}/cantor/latex)
......@@ -14,7 +14,15 @@ The version included here provides two additional patches:
* Better recognition of the mathematical expressions between $...$, $$...$$
## standalone.cls
This file provides the LaTeX class and package 'standalone' ([link](https://ctan.org/tex-archive/macros/latex/contrib/standalone)),
which allows TeX pictures or other TeX code in sub-files to be compiled standalone or as part of a main document.
This package is used for the rendering of mathematical LaTeX expressions embedded in the Cantor's worksheet.
## preview.sty
This file provides the LaTeX style 'preview' ([link](https://www.ctan.org/tex-archive/macros/latex/contrib/preview)).
The main purpose of the preview package is the extraction of selected
elements from a LaTeX source, like formulas or graphics, into separate
pages of a DVI file. A flexible and convenient interface allows it to
specify what commands and constructs should be extracted. This works
with DVI files postprocessed by either Dvips and Ghostscript or
dvipng, but it also works when you are using PDFTeX for generating PDF
files.
This package is used for the rendering of mathematical LaTeX expressions embedded in Cantor's worksheet.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment