Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export PDF Including *.SVG images/figures using Extension 'sphinx.ext.imgconverter' #4789

Closed
bernaloo opened this issue Mar 27, 2018 · 5 comments

Comments

@bernaloo
Copy link

bernaloo commented Mar 27, 2018

Subject: <Latex error when Exporting PDF ("make latexpdf") Including *.SVG images/figures using Extension 'sphinx.ext.imgconverter'>

Problem

Procedure to reproduce the problem

make pdflatex

using conf.py:

# -*- coding: utf-8 -*-
#
#  documentation build configuration file, created by
# sphinx-quickstart on Tue Mar 20 17:00:00 2018.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
    'sphinx.ext.doctest',
    'sphinx.ext.intersphinx',
    'sphinx.ext.todo',
    'sphinx.ext.coverage',
    'sphinx.ext.mathjax',
    'sphinx.ext.ifconfig',
    'sphinx.ext.viewcode',
    'sphinx.ext.githubpages',
	'sphinx.ext.imgconverter']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']


#latex_engine = 'lualatex'
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u''
copyright = u''
author = u''

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'0'
# The full version, including alpha/beta/rc tags.
release = u'1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'de'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
    '**': [
        'relations.html',  # needs 'show_related': True theme option to display
        'searchbox.html',
    ]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = ''


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
    # The paper size ('letterpaper' or 'a4paper').
    #
    # 'papersize': 'letterpaper',

    # The font size ('10pt', '11pt' or '12pt').
    #
    # 'pointsize': '10pt',

    # Additional stuff for the LaTeX preamble.
    #
'preamble': '\\usepackage{tikz}',
'preamble': '\\usepackage{svg}',


    # Latex figure (float) alignment
    #
    # 'figure_align': 'htbp',
	

}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [
    (master_doc, '', u'',
     u'', 'manual'),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    (master_doc, '', u'',
     [author], 1)
]


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (master_doc, '',
     author, '', 'One line description of project.',
     'Miscellaneous'),
]



# -- Options for Epub output ----------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']



# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}

Error logs / results

! LaTeX Error: Unknown graphics extension: .svg.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.99 \noindent\sphinxincludegraphics{{test}.svg}

?

Expected results

I

Reproducible project / your project

Environment info

  • OS: Windows
  • Python version: Python 2.7.13
  • Sphinx version: Running Sphinx v1.7.2
  • <Extra tools e.g.: Browser, tex or something else>
@tk0miya
Copy link
Member

tk0miya commented Mar 27, 2018

Could you paste a log from make latex command?

FYI: Quoting triple-backtick (```) might help you. It makes a block better looking:

```
blah blah blah
blah blah blah
blah blah blah
blah blah blah
```

@bernaloo
Copy link
Author

this is what I get


$ make latexpdf
Running Sphinx v1.7.2
loading translations [de]... done
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [latex]: all documents
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] index
C:\Projekte\path\source\index.rst:9: WARNING: toctree contains reference to nonexisting document u'Allgmeines'
looking for now-outdated files... none found
pickling environment... done
checking consistency... C:\Projekte\path\source\Allgemeines.rst: WARNING: document isn't included in any toctree
done
processing filename.tex...index filename?
resolving references...
Ung▒ltige Laufwerkangabe.
writing... done
copying images... [100%] test.svg
copying TeX support files...
done
build succeeded, 2 warnings.

The LaTeX files are in build\latex.
make[1]: Verzeichnis „/cygdrive/c/Projekte/latex“ wird betreten
pdflatex  'filename.tex'
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6630 64-bit)
entering extended mode
(filename.tex
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 75 language(s) loaded.
(sphinxmanual.cls
Document Class: sphinxmanual 2017/03/26 v1.6 Document class (Sphinx manual)

("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\repo
rt.cls"
Document Class: report 2014/09/29 v1.4h Standard LaTeX document class

("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\size
10.clo")))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\inpu
tenc.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\utf8
.def"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\t1en
c.dfu")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\ot1e
nc.dfu")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\omse
nc.dfu")))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\cmap\cmap
.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\font
enc.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\t1en
c.def")<<t1.cmap>>)
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\a
msmath.sty"
For additional information on amsmath, use the `?' option.

("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\a
mstext.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\a
msgen.sty"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\a
msbsy.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\a
msopn.sty"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsfonts\
amssymb.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsfonts\
amsfonts.sty"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\babel\b
abel.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\babel\s
witch.def")
*************************************
* Local config file bblopts.cfg used
*

("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\arabi\bbl
opts.cfg")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\babel-ger
man\ngerman.ldf"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\babel-ger
man\ngermanb.ldf"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\babel\b
abel.def"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\babel\t
xtbabel.def")))))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\psnfss\ti
mes.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\fncychap\
fncychap.sty") (sphinx.sty
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdie
k\ltxcmds.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\
graphicx.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\
keyval.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\
graphics.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\
trig.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics-
cfg\graphics.cfg")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics-
def\pdftex.def")))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\fancyhdr\
fancyhdr.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\text
comp.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\ts1e
nc.def"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\ts1e
nc.dfu")))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\titlesec\
titlesec.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\tabulary\
tabulary.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\tools\arr
ay.sty"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\tools\lon
gtable.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\ltxmisc\v
arwidth.sty") (sphinxmulticell.sty)
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\make
idx.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\framed\fr
amed.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\xcolor\xc
olor.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics-
cfg\color.cfg"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\fancyvrb\
fancyvrb.sty"
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix
<2008/02/07> (tvz)) (footnotehyper-sphinx.sty)
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\float\flo
at.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\wrapfig\w
rapfig.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\ltxmisc\p
arskip.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\allt
t.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\upquote\u
pquote.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\capt-of\c
apt-of.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\needspace
\needspace.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\carlisle\
remreset.sty") (sphinxhighlight.sty)
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\
kvoptions.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdie
k\kvsetkeys.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdie
k\infwarerr.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdie
k\etexcmds.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdie
k\ifluatex.sty")))))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\geometry\
geometry.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdie
k\ifpdf.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdie
k\ifvtex.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\ifxetex
\ifxetex.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\geometry\
geometry.cfg"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\hyperref\
hyperref.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdie
k\hobsub-hyperref.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdie
k\hobsub-generic.sty"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\
auxhook.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\hyperref\
pd1enc.def")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\00miktex\
hyperref.cfg")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\hyperref\
puenc.def")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\url\url.s
ty"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\hyperref\
hpdftex.def"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\
rerunfilecheck.sty"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\
hypcap.sty")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\svg\svg.s
ty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\koma-scri
pt\scrbase.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\koma-scri
pt\scrlfile.sty"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\tools\she
llesc.sty"))
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\
transparent.sty")
Writing index file filename.idx
(filename.aux)
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\ts1c
mr.fd")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\psnfss\t1
ptm.fd")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\context\base\su
pp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
)
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\
epstopdf-base.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\
grfext.sty"))
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex

("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\hyperref\
nameref.sty"
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdie
k\gettitlestring.sty")) (filename.out)
(filename.out)
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\psnfss\t1
phv.fd")<<ot1.cmap>><<oml.cmap>><<oms.cmap>><<omx.cmap>>
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsfonts\
umsa.fd")
("C:\Users\normaluser\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsfonts\
umsb.fd") [1{C:/Users/normaluser/AppData/Local/MiKTeX/2.9/pdftex/config/pdf
tex.map}] [2]

Package hyperref Warning: old toc file detected, not used; run LaTeX again.

[1] [2]
Kapitel 1.
[1] [2]
Kapitel 2.

! LaTeX Error: Unknown graphics extension: .svg.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.99 \noindent\sphinxincludegraphics{{test}.svg}

?


@jfbu
Copy link
Contributor

jfbu commented Mar 27, 2018

Unrelated but your latex_elements is wrong:

'preamble': '\\usepackage{tikz}',
'preamble': '\\usepackage{svg}',

this means the latex output will only have \usepackage{svg}.

I had a bigger problem with

latex_documents = [
    (master_doc, '', u'',
     u'', 'manual'),
]

this provokes

Exception occurred:
  File "/path/to/python3.6/site-packages/docutils/io.py", line 367, in open
    self.destination_path)
docutils.io.OutputError: [Errno 21] Is a directory: '/pathto/sphinxtests/NEWFOO/_build/latex/'

which is fixed by using config like this

latex_documents = [
    (master_doc, 'foo.tex', u'foo', u'bar', 'manual'),
]

After that I tested (on Mac OS X) with minimal project index.rst

.. image:: testpsspecials.svg

and the svg file is converted on the fly to png into latex output directory and the foo.tex file contains

\noindent\sphinxincludegraphics{{testpsspecials}.png}

As an aside, your usepackage{svg} can not work because the pdflatex must be executed with --shell-escape option. You have to do it manually. Of course Sphinx distribued Makefiles will never invoke pdflatex with --shell-escape option, for security reasons.

And the above should look like

\noindent\includesvg{{testpsspecials}.svg}

so you would need a sed script to transform Sphinx latex output into suitable form. It will be better when an extension built upon sphinx.ext.imgconverter uses inkscape automatically to produce pdf output from svg for LaTeX inclusion in pdf build.

But I see you are on Windows. There the convert command is something completely different than ImageMagick convert. @tk0miya maybe the test in imgconverter.py whether convert command can be run is no good on Windows ? (I can't test).

@tk0miya
Copy link
Member

tk0miya commented Mar 28, 2018

Good point. Surely, Windows provides another convert command.
It seems imgconverter wrongly detects that Imagemagick is installed. This must be a bug of imgconverter.

@tk0miya tk0miya added this to the 1.7.3 milestone Mar 28, 2018
tk0miya added a commit that referenced this issue Apr 1, 2018
…nvert_command

Fix #4789: imgconverter: confused by converter.exe of Windows
@tk0miya
Copy link
Member

tk0miya commented Apr 1, 2018

I fixed detection logic for Imagemagick at #4797. With this change, imgconverter emits warning if imagemagick not installed.

@bernaloo Please install imagemagick to make sphinx.ext.imgconverter enabled.

@tk0miya tk0miya closed this as completed Apr 1, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants