1
$\begingroup$

I am trying to generate "Program" cells but my issue is unlike "Code" cells, "Program" cells automatically start text wrapping when the line is too long for the screen. Is there an option or something to make these "Program" cells not have text wrapping so very long lines of code can go off-screen but remain in the same line like "Code" cells.

Here is an example "Program" cell:

long=StringJoin@Table[".",1000];
CellPrint@Cell[TextData[{
    StyleBox["Code:",FontWeight->"Bold"],"   ",
    " ... very long piece of code "<>long,"\n",
    StyleBox["Comment:",FontWeight->"Bold"],
    " ... very long comment ......"<>long
}], "Program"]

Here is an example "Code" cell:

CellPrint@Cell[TextData[{
    StyleBox["Code:",FontWeight->"Bold"],"   ",
    " ... very long piece of code "<>long,"\n",
    StyleBox["Comment:",FontWeight->"Bold"],
    " ... very long comment ......"<>long
}], "Code"]
$\endgroup$

1 Answer 1

1
$\begingroup$

See if this works for you

long = StringJoin@Table[".", 1000];
CellPrint[
 Cell[TextData[{StyleBox["Code:", FontWeight -> "Bold"], "   ", 
    " ... very long piece of code " <> long, "\n", 
    StyleBox["Comment:", FontWeight -> "Bold"], 
    " ... very long comment ......" <> long}], "Program", 
  "PageWidth" -> Infinity]]
$\endgroup$
1
  • $\begingroup$ Thank you, it works! Weird I can't find this option in the Cell reference page but it is mentioned on the PageWidth reference page that it works with Cell. $\endgroup$
    – user13892
    May 23, 2020 at 2:27

Your Answer

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

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