When using stuff like:

CellPrint[Cell["Z/" <> ToString[Prime[n]] <> "Z", "Item"]]

How can I use dynamic functionality in there? I was planning to create a dynamic variable n and make it dynamic in there but it's not working. I tried using the following slider:

{Slider[Dynamic[n], {0, 100, 1}], Dynamic[n]}

And the following codes:

CellPrint[Cell["Z/" <> ToString[Prime[Dynamic[n]]] <> "Z", "Item"]]


CellPrint[Cell["Z/" <> ToString[Evaluate[Prime[Refresh[n, UpdateInterval -> 1]]]] <> "Z", "Item"]]

But it doesn't work.

  • $\begingroup$ Why do you need to use CellPrint instead of Print, and why can't you use Row instead of creating a string? $\endgroup$
    – Carl Woll
    Dec 23, 2021 at 23:22
  • $\begingroup$ @CarlWoll Print outputs this. $\endgroup$
    – Red Banana
    Dec 23, 2021 at 23:37
  • $\begingroup$ So, don't use a Cell wrapper $\endgroup$
    – Carl Woll
    Dec 23, 2021 at 23:46
  • $\begingroup$ @CarlWoll I need it to create an "Item" with an n that updates dynamically. $\endgroup$
    – Red Banana
    Dec 23, 2021 at 23:48

1 Answer 1


Perhaps this?:


Or perhaps:

   Row[{"Z/", Dynamic[Prime@n], "Z"}],
   ShowStringCharacters -> False]];
  • $\begingroup$ I need it to output an "Item". $\endgroup$
    – Red Banana
    Dec 24, 2021 at 0:39
  • 1
    $\begingroup$ @RedBanana Do you mean instead of ”Output”? Do you mean you can’t make that change yourself? $\endgroup$
    – Michael E2
    Dec 24, 2021 at 0:43
  • $\begingroup$ @RedBanana Sorry, I was on an iOS device and couldn’t read the question and enter an answer at the same time. — Oops, battery is dying, now, too. :) $\endgroup$
    – Michael E2
    Dec 24, 2021 at 0:45
  • $\begingroup$ This is perfect! Thank you very much! $\endgroup$
    – Red Banana
    Dec 24, 2021 at 4:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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