Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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: enter image description here

And here's what it looks like in Mathematica:

enter image description here

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)

enter image description here

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

Help would be very much appreciated.

share|improve this question
2  
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
1  
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
2  
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
1  
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

2 Answers 2

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

cell using program style

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:

cell with bars removed

share|improve this answer

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:

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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