1

I try to create an application that takes several inputs and represent them in a comprehensive manner. Let's say I have the following script:

x = 5
y = 'meters'
z = 'second'

and I want to get a pdf/output like this

The speed is 5 meters/second

Is there any way to do it? Thank you in advance

  • 4
    yes this is a verycommon thing to do instead of equality you use \def\myx{5} etc. If you want to have units exclusively better use siunitx package. – percusse May 11 '18 at 14:18
  • As it is right now, the question is very unclear. Please clarify the input, and the conversion to output. – Johannes_B May 12 '18 at 05:15

1 Answers1

1

Here's one way of doing it

enter image description here

Code:

\documentclass{article}
\begin{document}

\def\x/{5}
\def\y/{meters}
\def\z/{second}
The speed is \x/ \y//\z/

\def\x/{6}
\def\y/{kilometers}
\def\z/{hour}
The speed is \x/ \y//\z/

\end{document}

I used / to enable spaces after the macros, taking advice from this answer - 'Drawbacks of xspace'.

Milo
  • 9,440