Skip to content

Pass information from latex to python code #26

Answered by tobiasBora
dflvunoooooo asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, just create a new placeholder containing something like:

set placeholder eval={__WIDTH_LATEX__}{\lenToCmNoUnit{\textwidth}}

(this requires the very latest version from master, the older version had \lenToCm but you need to manually trim the cm at the end) You can choose using the optional argument the unit, for instance matplotlib expects inches:

MWE:

\documentclass{scrartcl} 

\usepackage{robust-externalize}

\begin{document}
\begin{figure}
  \centering
  \noindent\rule{.75\linewidth}{1mm}
  \begin{CacheMeCode}{python, set placeholder eval={__LINEWIDTH__}{\lenToCmNoUnit[in]{.75\linewidth}}}
import matplotlib.pyplot as plt
import matplotlib
from matplotlib.pyplot import figure
figur…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@dflvunoooooo
Comment options

@tobiasBora
Comment options

@dflvunoooooo
Comment options

Answer selected by dflvunoooooo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #23 on February 19, 2024 14:16.