I want a text box (or something like it) that I can put a long string of text not separated by spaces into. It's something like a license key (so it consists of characters A-Z, a-z, 0-9, underscores, and dashes).

I've looked into using tabular, minipage, fbox, parbox, mdframed, and I just can't seem to find the behavior I'm looking for (the text extends off the page because their text wrap is looking for spaces and dashes). It's frustrating and disappointing to have done so much research for a task that can be done in Word with a copy/paste...

Is there something I overlooked? Does anyone know a way I can accomplish this?


1 Answer 1


Here I set up a loop to spit out token by token with a \penalty0 following it (which allows breaks). I do it in \ttfamily, but that can be excised.

EDITED to support underscores.


enter image description here

This will work if the inputs are limited to "A-Z, a-z, 0-9, underscores, and dashes", as requested by the OP. In fact the prohibited characters in the input stream will be {, } and %.

  • Thank you for the excellent answer, this is amazing. I also appreciate the note on prohibited characters.
    – user132925
    May 5, 2017 at 16:46

Your Answer

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