# How to set horizontal alignment inside a custom environment, based on one of the parameters

So with this code using xparse :

\NewDocumentEnvironment{figwcommentary}{O{0.45} m m}
{ \adjustbox{valign=t} {\begin{minipage}{#1\textwidth} #2 \end{minipage} } }


That right=0.5\textwidth} should be right=(1-#1-.05)*\textwidth} which of course isn't valid code.

It looks like calc or fp can be used for this, but I can't figure out how to reference the passed parameter.

• Could you post a compilable code, not just a snippet? – Bernard Aug 12 '20 at 18:57
• It's quite hard to understand what your code is supposed to do. – egreg Aug 12 '20 at 22:00

\NewDocumentEnvironment{figwcommentary}{O{0.45} m m}