Public bug reported:
mnemosyne: 2.8+ds1-2
texlive-pictures: 2021.20220204-1
ubuntu: Ubuntu 22.04.5 LTS
dvipng: 1.15-1.1
texlive-latex-base: 2021.20220204-1
poppler-utils: 22.02.0-2ubuntu0.5
tl;dr problem: chemfig LaTeX package does not work in mnemosyne cards
steps to reproduce
0) make sure chemfig is installed correctly and generates code with other
programs (lyx)
ie
$ kpsewhich chemfig
/usr/share/texlive/texmf-dist/tex/generic/chemfig/chemfig.tex
1) add \usepackage{chemfig} to latex preamble in
~/.config/mnemosyne/config.py to ensure chemfig is loaded:
latex_preamble = r"""
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{chemfig}
\begin{document}
"""
note:
latex = "latex -interaction=nonstopmode"
dvipng = "dvipng -D 200 -T tight tmp.dvi"
which seems to be the default(?)
2) run mnemosyne
3) create a new card that uses chemfig
card:
<$>\chemfig{A-B}\qquad</$>
answer:
test
what should happen: the correct formula should be displayed
what actually happens: it's all garbled
why:
create an example tex document:
example.tex
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\chemfig{A-B}\qquad
\end{document}
cat examplem.tex | latex
(we don't seem to need the -interaction=nonstopmode due to it being
invoked on cli rather than however mnemosyne does it(?))
this leaves a file in texput.dvi (unlike the default for
-interaction=nonstopmode (?) / how mnemosyne does it which leaves a file
in tmp.dvi)
running dvipng on this file finally gives us a clue:
$dvipng textput.dvi
This is dvipng 1.15 Copyright 2002-2015 Jan-Ake Larsson
[1 <raw PostScriptdvipng warning: PostScript environment contains DVI commands
dvipng warning: PostScript environment contains DVI commands dvipng warning: No
image output from inclusion of raw PostScript > <raw PostScriptdvipng warning:
No image output from inclusion of raw PostScript > <raw PostScriptdvipng
warning: PostScript environment contains DVI commands dvipng warning: No image
output from inclusion of raw PostScript > <raw PostScriptdvipng warning: No
image output from inclusion of raw PostScript > <raw PostScriptdvipng warning:
PostScript environment contains DVI commands dvipng warning: No image output
from inclusion of raw PostScript > <raw PostScriptdvipng warning: No image
output from inclusion of raw PostScript > <raw PostScriptdvipng warning:
PostScript environment contains DVI commands dvipng warning: No image output
from inclusion of raw PostScript > <raw PostScriptdvipng warning: No image
output from inclusion of raw PostScript > <raw PostScriptdvipng warning:
PostScript environment contains DVI commands dvipng warning: PostScript
environment contains DVI commands dvipng warning: PostScript environment
contains DVI commands dvipng warning: PostScript environment contains DVI
commands dvipng warning: PostScript environment contains DVI commands dvipng
warning: PostScript environment contains DVI commands dvipng warning: No image
output from inclusion of raw PostScript >]
as per
https://lists.nongnu.org/archive/html/dvipng/2015-03/msg00002.html
even if you have the correct texlive packages installed
and even if you setup mnemosyne to import the chemfig package in the right order
and even if your chemfig LaTeX is valid according to their syntax
this is expected behavior for dvipng : dvipng *doesn't actually support*
the kinds of dvi file that gets created by latex when you use the
chemfig package. At least in that post, the author suggested 2 fixes on
the dvi side which were both were substantial changes. This could mean
the "bug" here is in dvi.
however he suggests a workaround: using pdf as an intermediary form instead of
dvi
and realistically: mnemosyne users aren't really going to care whether or not
there's some internal format "dvi" which supports or doesn't support
chemfig-related functionality internaly, the problem here is that *mnemosyne
uses dvipng in such a way that chemfig is not supported*
the suggested workaround would mean something like:
pdflatex [-interaction=nonstopmode]
pdftoppm -png -r 200 tmp.pdf tmp
or
latex -output-format pdf -interaction=nonstopmode
pdftoppm -png -singlefile -r 200 tmp.pdf tmp
using pdflatex + pdftoppm on the commandline to generate a chemfig using
LaTeX *does* generate the correct png (though the resulting png seems
big -- and Jan-Åke Larsson warned this would happen above, which might
makes this a separate issue), so we know that mnemosyne *can* in
principle be made to use pdftoppm
however attempting to plug these two into config.py seems to result in
the generic 'is latex / dvipng installed?' message. Part of the problem
seems to be I'm not 100% sure what filename pdflatex / latex -output-
format seems to be generating or what mnemosyne is expecting(tmp.png?
tmp1.png?).
so the options here seem to be :
1) consider this a dvipng bug (dvipng needs driver for pgf) or
2) consider this a dvipng bug (dvipng needs an internal Postscript interpreter)
3) consider this a *mnemosyne* bug and
3.i) switch away from using dvipng to pdftoppm by default just by using dvipng
config.py variable to invoke it in the right way somehow
3.ii) change the dvipng variable in config.py altogether
3.iii) hacky but : have a separate latex processing stream for anything that
touches chemfig and any other and keep the dvipng there for everything else
ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: mnemosyne 2.8+ds1-2
Uname: Linux 6.0.7-gnulibre-squashfix x86_64
ApportVersion: 2.20.11-0ubuntu82.6
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: ubuntu:GNOME
Date: Fri Dec 13 12:43:09 2024
InstallationDate: Installed on 2017-04-18 (2796 days ago)
InstallationMedia: Ubuntu 17.04 "Zesty Zapus" - Release amd64 (20170412)
PackageArchitecture: all
RebootRequiredPkgs: Error: path contained symlinks.
SourcePackage: mnemosyne
UpgradeStatus: Upgraded to jammy on 2023-06-14 (547 days ago)
mtime.conffile..etc.apport.crashdb.conf: 2020-06-07T21:16:26.397404
** Affects: mnemosyne (Ubuntu)
Importance: Undecided
Status: New
** Tags: amd64 apport-bug jammy wayland-session
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2091734
Title:
chemfig LaTeX package doesn't work with dvipng
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mnemosyne/+bug/2091734/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs