What font to use for source code in a document?
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
I'm currently writing some text where I discuss a python script.
So naturally, there's a lot of code in the document and it seems like listings is the default way to do so.
However, unlike what I'm used to when using latex, the default looks atrocious!
Non-monospaced source code!? WTF? (side question: or is there really a typographic "rule" for this?)
OK, I can fix that after a quick read of the docs with ttfamily
.
But this is still very weird, mostly the italic part for the comments. It just looks totally off to me.
Is this because I just happen to be used to weird fonts in my editors (Monospace Regular
, not too weird, I'd guess) and this is normal and typographically sound, or is there a better option?
And if so, what would that option be? I'd rather not use some random font that I, personally, like but that is objectively bad, especially in combination with my default fonts for the text (all from Komas scrbook
).
Edit:*
Obviously, I can just use "random" monospaced/typewriter fonts, but my main concern is that I'll just pick one that will not work (typographically) with the default computer modern for the body of the document. So not only should the font work as a monospaced font for readable source code, it should also not look "off" next to computer modern.
So some kind of website listing font X is compatible with font Y
would probably be the most useful, but I haven't found one yet.
MWE:
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstsetlanguage=Python, numbers=left, numberstyle=tiny, stepnumber=1, numbersep=5pt, tabsize=4%, basicstyle=ttfamily}
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
fonts code lstlisting
add a comment |Â
up vote
4
down vote
favorite
I'm currently writing some text where I discuss a python script.
So naturally, there's a lot of code in the document and it seems like listings is the default way to do so.
However, unlike what I'm used to when using latex, the default looks atrocious!
Non-monospaced source code!? WTF? (side question: or is there really a typographic "rule" for this?)
OK, I can fix that after a quick read of the docs with ttfamily
.
But this is still very weird, mostly the italic part for the comments. It just looks totally off to me.
Is this because I just happen to be used to weird fonts in my editors (Monospace Regular
, not too weird, I'd guess) and this is normal and typographically sound, or is there a better option?
And if so, what would that option be? I'd rather not use some random font that I, personally, like but that is objectively bad, especially in combination with my default fonts for the text (all from Komas scrbook
).
Edit:*
Obviously, I can just use "random" monospaced/typewriter fonts, but my main concern is that I'll just pick one that will not work (typographically) with the default computer modern for the body of the document. So not only should the font work as a monospaced font for readable source code, it should also not look "off" next to computer modern.
So some kind of website listing font X is compatible with font Y
would probably be the most useful, but I haven't found one yet.
MWE:
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstsetlanguage=Python, numbers=left, numberstyle=tiny, stepnumber=1, numbersep=5pt, tabsize=4%, basicstyle=ttfamily}
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
fonts code lstlisting
You probably want to addcolumns=fullflexible, keepspaces=true,
into yourlstset
...
â Thruston
12 hours ago
Source code and similar text printed in a fairly "wide" sans-serif non-monospaced font usually looks fine, unless there is a reason you need to line up the text columns. In Python you certainly need to line up the Indents at the start of lines, because they encode the logical structure of the code, but I don't see why the rest of the line would need to be monospaced. FWIW Algol code (an early block structured language) was printed in books with proportionally spaced fonts right from the time the language was invented in the 1960s - long before TeX.
â alephzero
7 hours ago
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I'm currently writing some text where I discuss a python script.
So naturally, there's a lot of code in the document and it seems like listings is the default way to do so.
However, unlike what I'm used to when using latex, the default looks atrocious!
Non-monospaced source code!? WTF? (side question: or is there really a typographic "rule" for this?)
OK, I can fix that after a quick read of the docs with ttfamily
.
But this is still very weird, mostly the italic part for the comments. It just looks totally off to me.
Is this because I just happen to be used to weird fonts in my editors (Monospace Regular
, not too weird, I'd guess) and this is normal and typographically sound, or is there a better option?
And if so, what would that option be? I'd rather not use some random font that I, personally, like but that is objectively bad, especially in combination with my default fonts for the text (all from Komas scrbook
).
Edit:*
Obviously, I can just use "random" monospaced/typewriter fonts, but my main concern is that I'll just pick one that will not work (typographically) with the default computer modern for the body of the document. So not only should the font work as a monospaced font for readable source code, it should also not look "off" next to computer modern.
So some kind of website listing font X is compatible with font Y
would probably be the most useful, but I haven't found one yet.
MWE:
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstsetlanguage=Python, numbers=left, numberstyle=tiny, stepnumber=1, numbersep=5pt, tabsize=4%, basicstyle=ttfamily}
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
fonts code lstlisting
I'm currently writing some text where I discuss a python script.
So naturally, there's a lot of code in the document and it seems like listings is the default way to do so.
However, unlike what I'm used to when using latex, the default looks atrocious!
Non-monospaced source code!? WTF? (side question: or is there really a typographic "rule" for this?)
OK, I can fix that after a quick read of the docs with ttfamily
.
But this is still very weird, mostly the italic part for the comments. It just looks totally off to me.
Is this because I just happen to be used to weird fonts in my editors (Monospace Regular
, not too weird, I'd guess) and this is normal and typographically sound, or is there a better option?
And if so, what would that option be? I'd rather not use some random font that I, personally, like but that is objectively bad, especially in combination with my default fonts for the text (all from Komas scrbook
).
Edit:*
Obviously, I can just use "random" monospaced/typewriter fonts, but my main concern is that I'll just pick one that will not work (typographically) with the default computer modern for the body of the document. So not only should the font work as a monospaced font for readable source code, it should also not look "off" next to computer modern.
So some kind of website listing font X is compatible with font Y
would probably be the most useful, but I haven't found one yet.
MWE:
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstsetlanguage=Python, numbers=left, numberstyle=tiny, stepnumber=1, numbersep=5pt, tabsize=4%, basicstyle=ttfamily}
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
fonts code lstlisting
fonts code lstlisting
edited 10 hours ago
asked 12 hours ago
JC_CL
138115
138115
You probably want to addcolumns=fullflexible, keepspaces=true,
into yourlstset
...
â Thruston
12 hours ago
Source code and similar text printed in a fairly "wide" sans-serif non-monospaced font usually looks fine, unless there is a reason you need to line up the text columns. In Python you certainly need to line up the Indents at the start of lines, because they encode the logical structure of the code, but I don't see why the rest of the line would need to be monospaced. FWIW Algol code (an early block structured language) was printed in books with proportionally spaced fonts right from the time the language was invented in the 1960s - long before TeX.
â alephzero
7 hours ago
add a comment |Â
You probably want to addcolumns=fullflexible, keepspaces=true,
into yourlstset
...
â Thruston
12 hours ago
Source code and similar text printed in a fairly "wide" sans-serif non-monospaced font usually looks fine, unless there is a reason you need to line up the text columns. In Python you certainly need to line up the Indents at the start of lines, because they encode the logical structure of the code, but I don't see why the rest of the line would need to be monospaced. FWIW Algol code (an early block structured language) was printed in books with proportionally spaced fonts right from the time the language was invented in the 1960s - long before TeX.
â alephzero
7 hours ago
You probably want to add
columns=fullflexible, keepspaces=true,
into your lstset
...â Thruston
12 hours ago
You probably want to add
columns=fullflexible, keepspaces=true,
into your lstset
...â Thruston
12 hours ago
Source code and similar text printed in a fairly "wide" sans-serif non-monospaced font usually looks fine, unless there is a reason you need to line up the text columns. In Python you certainly need to line up the Indents at the start of lines, because they encode the logical structure of the code, but I don't see why the rest of the line would need to be monospaced. FWIW Algol code (an early block structured language) was printed in books with proportionally spaced fonts right from the time the language was invented in the 1960s - long before TeX.
â alephzero
7 hours ago
Source code and similar text printed in a fairly "wide" sans-serif non-monospaced font usually looks fine, unless there is a reason you need to line up the text columns. In Python you certainly need to line up the Indents at the start of lines, because they encode the logical structure of the code, but I don't see why the rest of the line would need to be monospaced. FWIW Algol code (an early block structured language) was printed in books with proportionally spaced fonts right from the time the language was invented in the 1960s - long before TeX.
â alephzero
7 hours ago
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
6
down vote
In my opinion the defaults in lstlisting
are very odd, but it's not hard to tame them. Here is your example with a few extra keys and some colour.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagexcolor
definecolortextbluergb.2,.2,.7
definecolortextredrgb0.54,0,0
definecolortextgreenrgb0,0.43,0
usepackagelistings
lstsetlanguage=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
keywordstyle=colortextblue,
commentstyle=colortextred,
stringstyle=colortextgreen,
frame=none,
columns=fullflexible,
keepspaces=true,
xleftmargin=parindent,
showstringspaces=false
begindocument
This is some other text.
beginlstlisting
for i in list:
print i, "OK"
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
If you wanted comments in italics, then you just add it to the commentstyle
line:
...
commentstyle=colortextreditshape,
...
this produces:
For more details do texdoc listings
...
If you don't like the look of the default ttfamily
then try some different ones. You may also need to change the body font to match the monofont of course, the default fonts may not be quite what you want, but at least they go together well.
This is stillttfamily
though, so having the comments in italics would just result in the same weirdness? Which of the settings controls the italics (or lack thereof), it's not readily apparent from the code.
â JC_CL
11 hours ago
@JC_CL Add to the preamble the lineusepackagesourcecodepro
, does this improve the result? OK, you need to have an installation including the Sourcecode Pro fonts.
â Keks Dose
11 hours ago
commentstyle=colortextreditshape
I see. was searching foritali
in the lstlisting docs and didn't find anything. The colors are all nice, but my main gripe is that italics look totally off, but (as per most editor defaults) comments should be in italics.usepackagesourcecodepro
gives me an error, even though I installed the font, but this probably gets me into "how to mix and match fonts in a document?" hell, as does the linked question, something I'd have hoped to avoid.
â JC_CL
10 hours ago
Computer Modern "typewriter italic" is one of the ugliest fonts ever invented IMO. Comic Sans is a lot better! I wonder what Knuth was thinking when he came up with it....
â alephzero
7 hours ago
add a comment |Â
up vote
5
down vote
It's not simply the serif font that makes the listing awful: it's mainly the font not being monospaced, so the characters look like being thrown on the page at random.
You might color the listing: good for screen reading, less good for printed paper.
Otherwise, you could look for different monospaced font (I don't like the italic default typewriter type too).
Here's a try with SourceCode Pro, just to see whether the result looks better.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
This is some other text.
% roughly emulate usepackagesourcecodepro
lstset
basicstyle=fontfamilySourceCodePro-TLFselectfont
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
OK, let's assume you like it. But it's definitely too big: we can fix it.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
usepackage[scale=0.85]sourcecodepro
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
There are several other monospaced fonts available, see the LaTeX font catalogue
A different choice might be LuxiMono:
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
usepackage[scaled=0.85]luximono
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i0123
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
I don't like the zero with a point inside, I find it unreadable.
â AndréC
10 hours ago
I on the other hand don't mind the dot⦠However, this font looks kinda off, compared to computer modern, and I'm no typographer that can judge if they fit. But it certainly is better than the atrocious italics in the default.
â JC_CL
10 hours ago
luximono looks a tad better to me, but that probably is subjective. And I'd like to avoid relying on my subjective judgement. I added some clarification in the main text, maybe someone knows about some "official" rules for that.
â JC_CL
10 hours ago
@JC_CL No "officialâ rule; personal taste is usually a good judge.
â egreg
10 hours ago
But isn't getting away from personal taste and instead using "professional" judgement the whole idea behind latex? Otherwise I'd just use Word with times new roman and comic sans like everyone else⦠Now I'm not saying that luximono is "wrong", but I also don't know if it is "right".
â JC_CL
10 hours ago
 |Â
show 1 more comment
up vote
2
down vote
Personally, for listing, the fundamental criterion is that the 0 is different from the letter O.
For the inconsolata
font is perfect.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstsetlanguage=Python, numbers=left, numberstyle=tiny, stepnumber=1, numbersep=5pt, tabsize=4, basicstyle=ttfamily
usepackageinconsolata
begindocument
This is some other text.
the 0 is not crossed out like the letter O
beginlstlisting
for i in list:
print i
# prints every entry in a list
# the 0 is crossed out unlike the letter O
endlstlisting
This here is also non, sourcecode text.
enddocument
1
0 vs. O is certainly important (and also not handled too well in the default), but it appears that inconsolata can't deal with italic comments. Also, I'm afraid that this the dreaded mixing of unmatching fonts.
â JC_CL
10 hours ago
@JC_CL Indeed, the inconsolata font has no italics.
â AndréC
10 hours ago
0 vs O was important back in the day when computers couldn't even print lower-case letters, but if you write code in the 21st century where you need to distinguish 0 and upper-case O (or 1, upper-case I and lower-case L) in your variable names, the best solution to that issue is not "find a different font" ;)
â alephzero
6 hours ago
@alephzero What is the best solution then?
â AndréC
6 hours ago
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
In my opinion the defaults in lstlisting
are very odd, but it's not hard to tame them. Here is your example with a few extra keys and some colour.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagexcolor
definecolortextbluergb.2,.2,.7
definecolortextredrgb0.54,0,0
definecolortextgreenrgb0,0.43,0
usepackagelistings
lstsetlanguage=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
keywordstyle=colortextblue,
commentstyle=colortextred,
stringstyle=colortextgreen,
frame=none,
columns=fullflexible,
keepspaces=true,
xleftmargin=parindent,
showstringspaces=false
begindocument
This is some other text.
beginlstlisting
for i in list:
print i, "OK"
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
If you wanted comments in italics, then you just add it to the commentstyle
line:
...
commentstyle=colortextreditshape,
...
this produces:
For more details do texdoc listings
...
If you don't like the look of the default ttfamily
then try some different ones. You may also need to change the body font to match the monofont of course, the default fonts may not be quite what you want, but at least they go together well.
This is stillttfamily
though, so having the comments in italics would just result in the same weirdness? Which of the settings controls the italics (or lack thereof), it's not readily apparent from the code.
â JC_CL
11 hours ago
@JC_CL Add to the preamble the lineusepackagesourcecodepro
, does this improve the result? OK, you need to have an installation including the Sourcecode Pro fonts.
â Keks Dose
11 hours ago
commentstyle=colortextreditshape
I see. was searching foritali
in the lstlisting docs and didn't find anything. The colors are all nice, but my main gripe is that italics look totally off, but (as per most editor defaults) comments should be in italics.usepackagesourcecodepro
gives me an error, even though I installed the font, but this probably gets me into "how to mix and match fonts in a document?" hell, as does the linked question, something I'd have hoped to avoid.
â JC_CL
10 hours ago
Computer Modern "typewriter italic" is one of the ugliest fonts ever invented IMO. Comic Sans is a lot better! I wonder what Knuth was thinking when he came up with it....
â alephzero
7 hours ago
add a comment |Â
up vote
6
down vote
In my opinion the defaults in lstlisting
are very odd, but it's not hard to tame them. Here is your example with a few extra keys and some colour.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagexcolor
definecolortextbluergb.2,.2,.7
definecolortextredrgb0.54,0,0
definecolortextgreenrgb0,0.43,0
usepackagelistings
lstsetlanguage=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
keywordstyle=colortextblue,
commentstyle=colortextred,
stringstyle=colortextgreen,
frame=none,
columns=fullflexible,
keepspaces=true,
xleftmargin=parindent,
showstringspaces=false
begindocument
This is some other text.
beginlstlisting
for i in list:
print i, "OK"
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
If you wanted comments in italics, then you just add it to the commentstyle
line:
...
commentstyle=colortextreditshape,
...
this produces:
For more details do texdoc listings
...
If you don't like the look of the default ttfamily
then try some different ones. You may also need to change the body font to match the monofont of course, the default fonts may not be quite what you want, but at least they go together well.
This is stillttfamily
though, so having the comments in italics would just result in the same weirdness? Which of the settings controls the italics (or lack thereof), it's not readily apparent from the code.
â JC_CL
11 hours ago
@JC_CL Add to the preamble the lineusepackagesourcecodepro
, does this improve the result? OK, you need to have an installation including the Sourcecode Pro fonts.
â Keks Dose
11 hours ago
commentstyle=colortextreditshape
I see. was searching foritali
in the lstlisting docs and didn't find anything. The colors are all nice, but my main gripe is that italics look totally off, but (as per most editor defaults) comments should be in italics.usepackagesourcecodepro
gives me an error, even though I installed the font, but this probably gets me into "how to mix and match fonts in a document?" hell, as does the linked question, something I'd have hoped to avoid.
â JC_CL
10 hours ago
Computer Modern "typewriter italic" is one of the ugliest fonts ever invented IMO. Comic Sans is a lot better! I wonder what Knuth was thinking when he came up with it....
â alephzero
7 hours ago
add a comment |Â
up vote
6
down vote
up vote
6
down vote
In my opinion the defaults in lstlisting
are very odd, but it's not hard to tame them. Here is your example with a few extra keys and some colour.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagexcolor
definecolortextbluergb.2,.2,.7
definecolortextredrgb0.54,0,0
definecolortextgreenrgb0,0.43,0
usepackagelistings
lstsetlanguage=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
keywordstyle=colortextblue,
commentstyle=colortextred,
stringstyle=colortextgreen,
frame=none,
columns=fullflexible,
keepspaces=true,
xleftmargin=parindent,
showstringspaces=false
begindocument
This is some other text.
beginlstlisting
for i in list:
print i, "OK"
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
If you wanted comments in italics, then you just add it to the commentstyle
line:
...
commentstyle=colortextreditshape,
...
this produces:
For more details do texdoc listings
...
If you don't like the look of the default ttfamily
then try some different ones. You may also need to change the body font to match the monofont of course, the default fonts may not be quite what you want, but at least they go together well.
In my opinion the defaults in lstlisting
are very odd, but it's not hard to tame them. Here is your example with a few extra keys and some colour.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagexcolor
definecolortextbluergb.2,.2,.7
definecolortextredrgb0.54,0,0
definecolortextgreenrgb0,0.43,0
usepackagelistings
lstsetlanguage=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
keywordstyle=colortextblue,
commentstyle=colortextred,
stringstyle=colortextgreen,
frame=none,
columns=fullflexible,
keepspaces=true,
xleftmargin=parindent,
showstringspaces=false
begindocument
This is some other text.
beginlstlisting
for i in list:
print i, "OK"
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
If you wanted comments in italics, then you just add it to the commentstyle
line:
...
commentstyle=colortextreditshape,
...
this produces:
For more details do texdoc listings
...
If you don't like the look of the default ttfamily
then try some different ones. You may also need to change the body font to match the monofont of course, the default fonts may not be quite what you want, but at least they go together well.
edited 11 hours ago
answered 11 hours ago
Thruston
24.9k23988
24.9k23988
This is stillttfamily
though, so having the comments in italics would just result in the same weirdness? Which of the settings controls the italics (or lack thereof), it's not readily apparent from the code.
â JC_CL
11 hours ago
@JC_CL Add to the preamble the lineusepackagesourcecodepro
, does this improve the result? OK, you need to have an installation including the Sourcecode Pro fonts.
â Keks Dose
11 hours ago
commentstyle=colortextreditshape
I see. was searching foritali
in the lstlisting docs and didn't find anything. The colors are all nice, but my main gripe is that italics look totally off, but (as per most editor defaults) comments should be in italics.usepackagesourcecodepro
gives me an error, even though I installed the font, but this probably gets me into "how to mix and match fonts in a document?" hell, as does the linked question, something I'd have hoped to avoid.
â JC_CL
10 hours ago
Computer Modern "typewriter italic" is one of the ugliest fonts ever invented IMO. Comic Sans is a lot better! I wonder what Knuth was thinking when he came up with it....
â alephzero
7 hours ago
add a comment |Â
This is stillttfamily
though, so having the comments in italics would just result in the same weirdness? Which of the settings controls the italics (or lack thereof), it's not readily apparent from the code.
â JC_CL
11 hours ago
@JC_CL Add to the preamble the lineusepackagesourcecodepro
, does this improve the result? OK, you need to have an installation including the Sourcecode Pro fonts.
â Keks Dose
11 hours ago
commentstyle=colortextreditshape
I see. was searching foritali
in the lstlisting docs and didn't find anything. The colors are all nice, but my main gripe is that italics look totally off, but (as per most editor defaults) comments should be in italics.usepackagesourcecodepro
gives me an error, even though I installed the font, but this probably gets me into "how to mix and match fonts in a document?" hell, as does the linked question, something I'd have hoped to avoid.
â JC_CL
10 hours ago
Computer Modern "typewriter italic" is one of the ugliest fonts ever invented IMO. Comic Sans is a lot better! I wonder what Knuth was thinking when he came up with it....
â alephzero
7 hours ago
This is still
ttfamily
though, so having the comments in italics would just result in the same weirdness? Which of the settings controls the italics (or lack thereof), it's not readily apparent from the code.â JC_CL
11 hours ago
This is still
ttfamily
though, so having the comments in italics would just result in the same weirdness? Which of the settings controls the italics (or lack thereof), it's not readily apparent from the code.â JC_CL
11 hours ago
@JC_CL Add to the preamble the line
usepackagesourcecodepro
, does this improve the result? OK, you need to have an installation including the Sourcecode Pro fonts.â Keks Dose
11 hours ago
@JC_CL Add to the preamble the line
usepackagesourcecodepro
, does this improve the result? OK, you need to have an installation including the Sourcecode Pro fonts.â Keks Dose
11 hours ago
commentstyle=colortextreditshape
I see. was searching for itali
in the lstlisting docs and didn't find anything. The colors are all nice, but my main gripe is that italics look totally off, but (as per most editor defaults) comments should be in italics. usepackagesourcecodepro
gives me an error, even though I installed the font, but this probably gets me into "how to mix and match fonts in a document?" hell, as does the linked question, something I'd have hoped to avoid.â JC_CL
10 hours ago
commentstyle=colortextreditshape
I see. was searching for itali
in the lstlisting docs and didn't find anything. The colors are all nice, but my main gripe is that italics look totally off, but (as per most editor defaults) comments should be in italics. usepackagesourcecodepro
gives me an error, even though I installed the font, but this probably gets me into "how to mix and match fonts in a document?" hell, as does the linked question, something I'd have hoped to avoid.â JC_CL
10 hours ago
Computer Modern "typewriter italic" is one of the ugliest fonts ever invented IMO. Comic Sans is a lot better! I wonder what Knuth was thinking when he came up with it....
â alephzero
7 hours ago
Computer Modern "typewriter italic" is one of the ugliest fonts ever invented IMO. Comic Sans is a lot better! I wonder what Knuth was thinking when he came up with it....
â alephzero
7 hours ago
add a comment |Â
up vote
5
down vote
It's not simply the serif font that makes the listing awful: it's mainly the font not being monospaced, so the characters look like being thrown on the page at random.
You might color the listing: good for screen reading, less good for printed paper.
Otherwise, you could look for different monospaced font (I don't like the italic default typewriter type too).
Here's a try with SourceCode Pro, just to see whether the result looks better.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
This is some other text.
% roughly emulate usepackagesourcecodepro
lstset
basicstyle=fontfamilySourceCodePro-TLFselectfont
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
OK, let's assume you like it. But it's definitely too big: we can fix it.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
usepackage[scale=0.85]sourcecodepro
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
There are several other monospaced fonts available, see the LaTeX font catalogue
A different choice might be LuxiMono:
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
usepackage[scaled=0.85]luximono
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i0123
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
I don't like the zero with a point inside, I find it unreadable.
â AndréC
10 hours ago
I on the other hand don't mind the dot⦠However, this font looks kinda off, compared to computer modern, and I'm no typographer that can judge if they fit. But it certainly is better than the atrocious italics in the default.
â JC_CL
10 hours ago
luximono looks a tad better to me, but that probably is subjective. And I'd like to avoid relying on my subjective judgement. I added some clarification in the main text, maybe someone knows about some "official" rules for that.
â JC_CL
10 hours ago
@JC_CL No "officialâ rule; personal taste is usually a good judge.
â egreg
10 hours ago
But isn't getting away from personal taste and instead using "professional" judgement the whole idea behind latex? Otherwise I'd just use Word with times new roman and comic sans like everyone else⦠Now I'm not saying that luximono is "wrong", but I also don't know if it is "right".
â JC_CL
10 hours ago
 |Â
show 1 more comment
up vote
5
down vote
It's not simply the serif font that makes the listing awful: it's mainly the font not being monospaced, so the characters look like being thrown on the page at random.
You might color the listing: good for screen reading, less good for printed paper.
Otherwise, you could look for different monospaced font (I don't like the italic default typewriter type too).
Here's a try with SourceCode Pro, just to see whether the result looks better.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
This is some other text.
% roughly emulate usepackagesourcecodepro
lstset
basicstyle=fontfamilySourceCodePro-TLFselectfont
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
OK, let's assume you like it. But it's definitely too big: we can fix it.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
usepackage[scale=0.85]sourcecodepro
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
There are several other monospaced fonts available, see the LaTeX font catalogue
A different choice might be LuxiMono:
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
usepackage[scaled=0.85]luximono
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i0123
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
I don't like the zero with a point inside, I find it unreadable.
â AndréC
10 hours ago
I on the other hand don't mind the dot⦠However, this font looks kinda off, compared to computer modern, and I'm no typographer that can judge if they fit. But it certainly is better than the atrocious italics in the default.
â JC_CL
10 hours ago
luximono looks a tad better to me, but that probably is subjective. And I'd like to avoid relying on my subjective judgement. I added some clarification in the main text, maybe someone knows about some "official" rules for that.
â JC_CL
10 hours ago
@JC_CL No "officialâ rule; personal taste is usually a good judge.
â egreg
10 hours ago
But isn't getting away from personal taste and instead using "professional" judgement the whole idea behind latex? Otherwise I'd just use Word with times new roman and comic sans like everyone else⦠Now I'm not saying that luximono is "wrong", but I also don't know if it is "right".
â JC_CL
10 hours ago
 |Â
show 1 more comment
up vote
5
down vote
up vote
5
down vote
It's not simply the serif font that makes the listing awful: it's mainly the font not being monospaced, so the characters look like being thrown on the page at random.
You might color the listing: good for screen reading, less good for printed paper.
Otherwise, you could look for different monospaced font (I don't like the italic default typewriter type too).
Here's a try with SourceCode Pro, just to see whether the result looks better.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
This is some other text.
% roughly emulate usepackagesourcecodepro
lstset
basicstyle=fontfamilySourceCodePro-TLFselectfont
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
OK, let's assume you like it. But it's definitely too big: we can fix it.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
usepackage[scale=0.85]sourcecodepro
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
There are several other monospaced fonts available, see the LaTeX font catalogue
A different choice might be LuxiMono:
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
usepackage[scaled=0.85]luximono
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i0123
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
It's not simply the serif font that makes the listing awful: it's mainly the font not being monospaced, so the characters look like being thrown on the page at random.
You might color the listing: good for screen reading, less good for printed paper.
Otherwise, you could look for different monospaced font (I don't like the italic default typewriter type too).
Here's a try with SourceCode Pro, just to see whether the result looks better.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
This is some other text.
% roughly emulate usepackagesourcecodepro
lstset
basicstyle=fontfamilySourceCodePro-TLFselectfont
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
OK, let's assume you like it. But it's definitely too big: we can fix it.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
usepackage[scale=0.85]sourcecodepro
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
There are several other monospaced fonts available, see the LaTeX font catalogue
A different choice might be LuxiMono:
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
usepackage[scaled=0.85]luximono
lstset
language=Python,
numbers=left,
numberstyle=tiny,
stepnumber=1,
numbersep=5pt,
tabsize=4,
basicstyle=ttfamily,
columns=fullflexible,
keepspaces,
begindocument
This is some other text.
beginlstlisting
for i in list:
print i0123
# prints every entry in a list
endlstlisting
This here is also non, sourcecode text.
enddocument
edited 10 hours ago
answered 10 hours ago
egreg
688k8418323080
688k8418323080
I don't like the zero with a point inside, I find it unreadable.
â AndréC
10 hours ago
I on the other hand don't mind the dot⦠However, this font looks kinda off, compared to computer modern, and I'm no typographer that can judge if they fit. But it certainly is better than the atrocious italics in the default.
â JC_CL
10 hours ago
luximono looks a tad better to me, but that probably is subjective. And I'd like to avoid relying on my subjective judgement. I added some clarification in the main text, maybe someone knows about some "official" rules for that.
â JC_CL
10 hours ago
@JC_CL No "officialâ rule; personal taste is usually a good judge.
â egreg
10 hours ago
But isn't getting away from personal taste and instead using "professional" judgement the whole idea behind latex? Otherwise I'd just use Word with times new roman and comic sans like everyone else⦠Now I'm not saying that luximono is "wrong", but I also don't know if it is "right".
â JC_CL
10 hours ago
 |Â
show 1 more comment
I don't like the zero with a point inside, I find it unreadable.
â AndréC
10 hours ago
I on the other hand don't mind the dot⦠However, this font looks kinda off, compared to computer modern, and I'm no typographer that can judge if they fit. But it certainly is better than the atrocious italics in the default.
â JC_CL
10 hours ago
luximono looks a tad better to me, but that probably is subjective. And I'd like to avoid relying on my subjective judgement. I added some clarification in the main text, maybe someone knows about some "official" rules for that.
â JC_CL
10 hours ago
@JC_CL No "officialâ rule; personal taste is usually a good judge.
â egreg
10 hours ago
But isn't getting away from personal taste and instead using "professional" judgement the whole idea behind latex? Otherwise I'd just use Word with times new roman and comic sans like everyone else⦠Now I'm not saying that luximono is "wrong", but I also don't know if it is "right".
â JC_CL
10 hours ago
I don't like the zero with a point inside, I find it unreadable.
â AndréC
10 hours ago
I don't like the zero with a point inside, I find it unreadable.
â AndréC
10 hours ago
I on the other hand don't mind the dot⦠However, this font looks kinda off, compared to computer modern, and I'm no typographer that can judge if they fit. But it certainly is better than the atrocious italics in the default.
â JC_CL
10 hours ago
I on the other hand don't mind the dot⦠However, this font looks kinda off, compared to computer modern, and I'm no typographer that can judge if they fit. But it certainly is better than the atrocious italics in the default.
â JC_CL
10 hours ago
luximono looks a tad better to me, but that probably is subjective. And I'd like to avoid relying on my subjective judgement. I added some clarification in the main text, maybe someone knows about some "official" rules for that.
â JC_CL
10 hours ago
luximono looks a tad better to me, but that probably is subjective. And I'd like to avoid relying on my subjective judgement. I added some clarification in the main text, maybe someone knows about some "official" rules for that.
â JC_CL
10 hours ago
@JC_CL No "officialâ rule; personal taste is usually a good judge.
â egreg
10 hours ago
@JC_CL No "officialâ rule; personal taste is usually a good judge.
â egreg
10 hours ago
But isn't getting away from personal taste and instead using "professional" judgement the whole idea behind latex? Otherwise I'd just use Word with times new roman and comic sans like everyone else⦠Now I'm not saying that luximono is "wrong", but I also don't know if it is "right".
â JC_CL
10 hours ago
But isn't getting away from personal taste and instead using "professional" judgement the whole idea behind latex? Otherwise I'd just use Word with times new roman and comic sans like everyone else⦠Now I'm not saying that luximono is "wrong", but I also don't know if it is "right".
â JC_CL
10 hours ago
 |Â
show 1 more comment
up vote
2
down vote
Personally, for listing, the fundamental criterion is that the 0 is different from the letter O.
For the inconsolata
font is perfect.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstsetlanguage=Python, numbers=left, numberstyle=tiny, stepnumber=1, numbersep=5pt, tabsize=4, basicstyle=ttfamily
usepackageinconsolata
begindocument
This is some other text.
the 0 is not crossed out like the letter O
beginlstlisting
for i in list:
print i
# prints every entry in a list
# the 0 is crossed out unlike the letter O
endlstlisting
This here is also non, sourcecode text.
enddocument
1
0 vs. O is certainly important (and also not handled too well in the default), but it appears that inconsolata can't deal with italic comments. Also, I'm afraid that this the dreaded mixing of unmatching fonts.
â JC_CL
10 hours ago
@JC_CL Indeed, the inconsolata font has no italics.
â AndréC
10 hours ago
0 vs O was important back in the day when computers couldn't even print lower-case letters, but if you write code in the 21st century where you need to distinguish 0 and upper-case O (or 1, upper-case I and lower-case L) in your variable names, the best solution to that issue is not "find a different font" ;)
â alephzero
6 hours ago
@alephzero What is the best solution then?
â AndréC
6 hours ago
add a comment |Â
up vote
2
down vote
Personally, for listing, the fundamental criterion is that the 0 is different from the letter O.
For the inconsolata
font is perfect.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstsetlanguage=Python, numbers=left, numberstyle=tiny, stepnumber=1, numbersep=5pt, tabsize=4, basicstyle=ttfamily
usepackageinconsolata
begindocument
This is some other text.
the 0 is not crossed out like the letter O
beginlstlisting
for i in list:
print i
# prints every entry in a list
# the 0 is crossed out unlike the letter O
endlstlisting
This here is also non, sourcecode text.
enddocument
1
0 vs. O is certainly important (and also not handled too well in the default), but it appears that inconsolata can't deal with italic comments. Also, I'm afraid that this the dreaded mixing of unmatching fonts.
â JC_CL
10 hours ago
@JC_CL Indeed, the inconsolata font has no italics.
â AndréC
10 hours ago
0 vs O was important back in the day when computers couldn't even print lower-case letters, but if you write code in the 21st century where you need to distinguish 0 and upper-case O (or 1, upper-case I and lower-case L) in your variable names, the best solution to that issue is not "find a different font" ;)
â alephzero
6 hours ago
@alephzero What is the best solution then?
â AndréC
6 hours ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Personally, for listing, the fundamental criterion is that the 0 is different from the letter O.
For the inconsolata
font is perfect.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstsetlanguage=Python, numbers=left, numberstyle=tiny, stepnumber=1, numbersep=5pt, tabsize=4, basicstyle=ttfamily
usepackageinconsolata
begindocument
This is some other text.
the 0 is not crossed out like the letter O
beginlstlisting
for i in list:
print i
# prints every entry in a list
# the 0 is crossed out unlike the letter O
endlstlisting
This here is also non, sourcecode text.
enddocument
Personally, for listing, the fundamental criterion is that the 0 is different from the letter O.
For the inconsolata
font is perfect.
documentclass[a4paper,11pt, headings=normal, toc=bibliography, toc=listof]scrbook
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagelistings
lstsetlanguage=Python, numbers=left, numberstyle=tiny, stepnumber=1, numbersep=5pt, tabsize=4, basicstyle=ttfamily
usepackageinconsolata
begindocument
This is some other text.
the 0 is not crossed out like the letter O
beginlstlisting
for i in list:
print i
# prints every entry in a list
# the 0 is crossed out unlike the letter O
endlstlisting
This here is also non, sourcecode text.
enddocument
edited 10 hours ago
answered 10 hours ago
AndréC
3,586729
3,586729
1
0 vs. O is certainly important (and also not handled too well in the default), but it appears that inconsolata can't deal with italic comments. Also, I'm afraid that this the dreaded mixing of unmatching fonts.
â JC_CL
10 hours ago
@JC_CL Indeed, the inconsolata font has no italics.
â AndréC
10 hours ago
0 vs O was important back in the day when computers couldn't even print lower-case letters, but if you write code in the 21st century where you need to distinguish 0 and upper-case O (or 1, upper-case I and lower-case L) in your variable names, the best solution to that issue is not "find a different font" ;)
â alephzero
6 hours ago
@alephzero What is the best solution then?
â AndréC
6 hours ago
add a comment |Â
1
0 vs. O is certainly important (and also not handled too well in the default), but it appears that inconsolata can't deal with italic comments. Also, I'm afraid that this the dreaded mixing of unmatching fonts.
â JC_CL
10 hours ago
@JC_CL Indeed, the inconsolata font has no italics.
â AndréC
10 hours ago
0 vs O was important back in the day when computers couldn't even print lower-case letters, but if you write code in the 21st century where you need to distinguish 0 and upper-case O (or 1, upper-case I and lower-case L) in your variable names, the best solution to that issue is not "find a different font" ;)
â alephzero
6 hours ago
@alephzero What is the best solution then?
â AndréC
6 hours ago
1
1
0 vs. O is certainly important (and also not handled too well in the default), but it appears that inconsolata can't deal with italic comments. Also, I'm afraid that this the dreaded mixing of unmatching fonts.
â JC_CL
10 hours ago
0 vs. O is certainly important (and also not handled too well in the default), but it appears that inconsolata can't deal with italic comments. Also, I'm afraid that this the dreaded mixing of unmatching fonts.
â JC_CL
10 hours ago
@JC_CL Indeed, the inconsolata font has no italics.
â AndréC
10 hours ago
@JC_CL Indeed, the inconsolata font has no italics.
â AndréC
10 hours ago
0 vs O was important back in the day when computers couldn't even print lower-case letters, but if you write code in the 21st century where you need to distinguish 0 and upper-case O (or 1, upper-case I and lower-case L) in your variable names, the best solution to that issue is not "find a different font" ;)
â alephzero
6 hours ago
0 vs O was important back in the day when computers couldn't even print lower-case letters, but if you write code in the 21st century where you need to distinguish 0 and upper-case O (or 1, upper-case I and lower-case L) in your variable names, the best solution to that issue is not "find a different font" ;)
â alephzero
6 hours ago
@alephzero What is the best solution then?
â AndréC
6 hours ago
@alephzero What is the best solution then?
â AndréC
6 hours ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f454492%2fwhat-font-to-use-for-source-code-in-a-document%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You probably want to add
columns=fullflexible, keepspaces=true,
into yourlstset
...â Thruston
12 hours ago
Source code and similar text printed in a fairly "wide" sans-serif non-monospaced font usually looks fine, unless there is a reason you need to line up the text columns. In Python you certainly need to line up the Indents at the start of lines, because they encode the logical structure of the code, but I don't see why the rest of the line would need to be monospaced. FWIW Algol code (an early block structured language) was printed in books with proportionally spaced fonts right from the time the language was invented in the 1960s - long before TeX.
â alephzero
7 hours ago