Reputation: 604
I'm using Windows Python 2.7.6 and iPython 2.0.0. When I do a print preview on a notebook, I get a gorgeous color output with syntax highlighting, etc.
As soon as I either do a print preview, or print it, it becomes gray scale and loses the syntax highlighting. How can I print keeping the color and highlighting?
Upvotes: 7
Views: 5253
Reputation: 979
One workaround is, save the notebook as html. The rendered file will have the css embedded. Open the HTML in a text editor and do a search for
@media print
and delete the offending
!important;color:#000
save, open the file in a browser and print.
It's not ideal but you don't have to go digging around changing the CSS and recompiling in your site-packages.
Just in case someone is looking for an easier workaround.
Upvotes: 10
Reputation: 1213
I know this is an old question, but for people who may be searching for this answer, here it is:
IPython on windows would be installed by default at C:\Python27\site-packages\IPython
. If you installed Python somewhere else, the beginning of the path will change. For linux users, it would be installed under /usr/lib/python2.7/site-packages/IPython
.
Once in the IPython folder, go to html\static\style
. You should then see a file called style.min.css
.
Making sure you have administrator priviledges, open style.min.css
with your favorite text editor. If you don't know what I mean by text editor, just double click. In style.min.css
find the line that starts with @media print
. On that line, near the beginning, you will see color: #000 !important;
Delete only that part of the line and save the file.
I have IPython 2.3.0, so it may be different in you version, but this is what the line I am talking about looks like before and after the change (only part of line is shown):
@media print{*{text-shadow:none !important;color:#000 !important;background:tran...
@media print{*{text-shadow:none !important;background:transparent !important;box...
Upvotes: 9