diff --git a/mlsshared.sty b/mlsshared.sty index 8320afc30..563a99e72 100644 --- a/mlsshared.sty +++ b/mlsshared.sty @@ -202,7 +202,7 @@ keepspaces, % don't remove space such as those after closing parenthesis upquote=true, % Don't turn apostrophe/backtick into single quotation marks. captionpos=b, % sets the caption-position to bottom - commentstyle=\color{commentcolor}\sffamily, + commentstyle=\color{commentcolor}\sffamilyifhtml, keywordstyle=\color{red}, % Unused keyword style in bright red to make it easy to detect and fix. keywordstyle=[1]\color{keywordcolor1}, keywordstyle=[2]\color{keywordcolor1}\bfseries, diff --git a/preamble.tex b/preamble.tex index 6e6868246..f44fb02e8 100644 --- a/preamble.tex +++ b/preamble.tex @@ -143,6 +143,15 @@ \let\smallifpdf\normalsize \fi +% Comments in listings looks better and more distinct from the actual code if set in a variable-width sans-serif font. +% However, just changing font family doesn't work for pdf. +% Hence, we make a different choice of font depending on the target format. +\ifpdf +\let\sffamilyifhtml\relax +\else +\let\sffamilyifhtml\sffamily +\fi + \ifpdf % Don't load cleveref yet. \else