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

pass max width to latex adjustbox #91

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion sphinxcontrib/plantuml.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def _lookup_latex_format(fmt):
)


def _latex_adjustbox_options(self, node):
def _latex_adjustbox_options(self, node): # noqa: C901
adjustbox_options = []
if 'width' in node:
if 'scale' in node:
Expand All @@ -651,6 +651,13 @@ def _latex_adjustbox_options(self, node):
if 'scale' in node:
if not adjustbox_options:
adjustbox_options.append('scale=%s' % (float(node['scale']) / 100.0))
if 'max-width' in node:
if 'scale' in node:
w = self.latex_image_length(node['max-width'], node['scale'])
else:
w = self.latex_image_length(node['max-width'])
if w:
adjustbox_options.append('max width=%s' % w)
return adjustbox_options


Expand Down
13 changes: 13 additions & 0 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,19 @@ def test_buildlatex_simple_height_with_tikz():
readfile('plantuml_fixture.tex'))


@with_runsphinx('latex', plantuml_latex_output_format='tikz')
def test_buildlatex_simple_max_width_with_tikz():
"""Generate simple LaTeX with TikZ

.. uml::
:max-width: 50mm

Hello
"""
assert re.search(br'\\adjustbox\{max width=50mm\}\{\\input\{+plantuml-',
readfile('plantuml_fixture.tex'))


@with_runsphinx('latex', plantuml_latex_output_format='pdf')
def test_buildlatex_simple_with_pdf():
"""Generate simple LaTeX with PDF
Expand Down
Loading