2
$\begingroup$

I've got a variable that has two names on it. It is defined as follows:

par={b, Subscript[λ, 0]}

I would like to ask the user to enter a value of the second variable inside par. What I am currently doing is

input=Input["Enter a value for parameter " <> ToString[par[[2]],StandardForm]]

The problem is that the input message appears in this way:

Input message

That is not a fancy way to show the message. How can I show the parameter par[[2]] as in LaTeX output?

$\endgroup$
1
  • 1
    $\begingroup$ input = Input[StringForm["Enter a value for parameter ``", par[[2]]]] $\endgroup$
    – Bob Hanlon
    Sep 20 at 22:38
5
$\begingroup$

I think it is much better to use Row instead of ToString and StringJoin, so I would recommend:

input = Input[Row[{"Enter a value for parameter ", par[[2]]}]]

However, if you absolutely must work with strings, you can do:

input = Input[StandardForm["Enter a value for parameter "<>ToString[par[[2]],StandardForm]]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.