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

maxwidth option not handled by latex writer #2

Open
flg opened this issue Apr 8, 2014 · 0 comments
Open

maxwidth option not handled by latex writer #2

flg opened this issue Apr 8, 2014 · 0 comments

Comments

@flg
Copy link

flg commented Apr 8, 2014

I needed to scale my seqdiags in the Latex output of a Sphinx doc. I wrote this little patch:

--- /usr/local/lib/python2.7/dist-packages/sphinxcontrib_seqdiag-0.6.0-py2.7.egg/sphinxcontrib/seqdiag.py       2014-04-08 14:55:21.395591062 +0200
+++ /home/legoff/Downloads/seqdiag.py.patched   2014-04-08 14:39:27.276320171 +0200
@@ -243,7 +243,14 @@
         raise nodes.SkipNode

     if fname is not None:
-        self.body.append('\\par\\includegraphics{%s}\\par' % fname)
+        # handle maxwidth option
+        image_size = image.pagesize()
+        if 'maxwidth' in options and options['maxwidth'] < image_size[0]:
+            ratio = float(options['maxwidth']) / image_size[0]
+            self.body.append('\\par\\includegraphics[scale=%f]{%s}\\par' % (ratio, fname))
+        else:
+            self.body.append('\\par\\includegraphics{%s}\\par' % fname)
+
     raise nodes.SkipNode

As you can see the patch is on version 0.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant