# Pasting monospaced text into Mathematica notebook destroys aligment

I drew the little ASCII-art electronics schema below in vim.

When i try to paste it into a Mathematica notebook, with:

A) A code cell
B) A monospaced font (Courier New)

Mathematica insists on destroying the vertical aligment.

Here is what it looks like in vim:

And here's what it looks like in Mathematica:

Even worse, when I try to re-align things by hand in the notebook, the end result looks very bad (note the misaligned vertical bars on the right hand side)

For something so simple to be so hard ... I must be missing something glaringly obvious.

Help would be very much appreciated.

• Why are you pasting text into a code cell? Code cells automatically format their contents. You'll never get it to look right. Perhaps you want to Import the file as a String? – Michael E2 Nov 30 '13 at 19:23
• Mathematica notebook really needs a verbatim cell and/or verbatim wrapper, where one can write Verbatim[" string "] and the content will show as is. No formating. As in Latex's verbatim environment ctan.org/pkg/verbatim, can be used for comments in code as well. Try making free form comments using (* *) and you'll see how hard it is to align the comments the way you want with the code. – Nasser Nov 30 '13 at 19:58
• As a side note, if you're interested more in drawing circuits than text alignment, you might find these useful: Circuit drawing in Mathematica and Graph layout on a grid – Michael E2 Nov 30 '13 at 20:03
• It works for me on my own example. But it's cool you found a solution. You should post it as answer to your own question, by the way. – Michael E2 Nov 30 '13 at 20:28
• Are you really pasting that into a Code cell or an Input cell? Code cells don't reformat the text, only Input cells do. Try pasting into an actual Code cell. Use Window -> Show Toolbar, select the cell bracket, change the cell style to "Code". Or insert a new cell using Alt-8 (Command-8 on Mac). – Szabolcs Dec 1 '13 at 4:29

The Program style is purpose-built for this sort of thing:

If you do not like the look of the bars above and below the cell, you can remove them by selecting the cell and changing the CellFrame option in the Option Inspector:

I seem to have found a solution, kind of convoluted, and not entirely sure why it works.

• Create a cell
• Cell -> Convert To -> Raw Input Form
• Open a comment in the cell
• Paste the ASCII art
• Close comment

This is what it looks like now: