Fonts for Displaying Program Code in L A TEX

Similar documents
New Font Offerings: Cochineal, Nimbus15, LibertinusT1Math

Introduction to Scientific Typesetting Lesson 14: Fonts

Present and future of the TG Math Project:the report and some qu

Customizing Graphical Reports

Chapter 7 Typography, Style Sheets, and Color. Mrs. Johnson

Chapter 12: FORMATTING TEXT

Text. Text metrics. There are some important metrics that we must consider when working with text. Figure 4-1 shows the basics.

Controlling Appearance the Old Way

PRESENTED BY : RIZWAN AARIF رضوان عارف

RMX. Font Remix Tools FOR GLYPHS. Handbook

Setting Up a Paper in APA Style Using Microsoft Word 2007

Typography. Text in Illustrator and InDesign. Martin Constable February 11, RMIT Vietnam

CSS. Text & Font Properties. Copyright DevelopIntelligence LLC

Web Site Design and Development Lecture 6

IT82: Mul timedia. Practical Graphics Issues 20th Feb Overview. Anti-aliasing. Fonts. What is it How to do it? History Anatomy of a Font

10 years of OpenType math font development

User-Centered Website Development: A Human- Computer Interaction Approach

Cascade Stylesheets (CSS)

The building block of a CSS stylesheet. A rule consists of a selector and a declaration block (one or more declarations).

Setting Up a Paper in APA Style Using Microsoft Word 2008 for MACs

RMX. Font Remix Tools. for glyphs. Handbook. February 2016 Just Another Foundry GmbH

Friendly Fonts for your Design

Admin. Midterm 1 on. Oct. 13 th (2 weeks from today) Coursework:

Fonts, text, and colour on the web. Sourcing, resizing, and inserting web site images MGMT 230 LAB

GO Transit type treatments report

T E X Gyre Pagella Math

COSC 2206 Internet Tools. CSS Cascading Style Sheets

Font, Typeface, Typeface Family. Selected Typographical Variables

Detailed Contents for TEX Unbound: Strategies for Font, Graphics, and More

Cascading Style Sheet Quick Reference

Appendix D CSS Properties and Values

Introduction to Web Tech and Programming

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets

InDesign. your. Resumé. a how-to guide for creating a professional resumé using InDesign

1 of 7 11/12/2009 9:29 AM

MODULE CM 2004 / STAGE 2 / SEMESTER 2 / SESSION Module title Design Principles and Context

CSS Styles Quick Reference Guide

CSS: Formatting Text. CSS for text processing: font-family. Robert A. Fulkerson

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values

How Typography Determines Readability: Serif vs. Sans Serif, and How To Combine Fonts.

escuela técnica superior de ingeniería informática

Selecting fonts from the WIRIS editor user interface Configuring fonts in the plugins and low level configuration... 2

An Introduction to L A T E X

Thai Printing Support in FOSS

- The CSS1 specification was developed in CSSs provide the means to control and change presentation of HTML documents

Reading 2.2 Cascading Style Sheets

TEMPLATE ORDER GUIDE /

Basic Text Formatting with L A T E X

Web Page Creation Part I. CS27101 Introduction to Web Interface Design Prof. Angela Guercio

Fundamentals of Web Programming a

Typography. is the foundation of good web design

Graphics and Painting

TYPE BASICS Cartographic Design & Principles Winter 2016

Meeting One. Aaron Ecay. February 2, 2011

Adding CSS to your HTML

We assume that occasionally you want to say something on your Web

EnvSci360 Computer and Analytical Cartography

3.1 Introduction. 3.2 Levels of Style Sheets. - The CSS1 specification was developed in There are three levels of style sheets

- The CSS1 specification was developed in CSS2 was released in CSS2.1 reflects browser implementations

The LibertinusT1 Math Package

Typesetting in wxmaxima

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2)

Additional catalogs display. Customize text size and colors.

HTML/XML. HTML Continued Introduction to CSS

uiophd a LATEX document class for PhD theses

CASCADING STYLESHEETS

PLT Fall Shoo. Language Reference Manual

Mathematical Font Art

Introduction to Web Design CSS Reference

Pan-Unicode Fonts. Text Layout Summit 2007 Glasgow, July 4-6. Ben Laenen, DejaVu Fonts

Introduction to Web Design CSS Reference

CMPT 165: More CSS Basics

Formatting APA Tables

Basic Elements > Typeface. Contents

Adobe Photoshop CS Design Professional PLACING TYPE IN AN IMAGE

IDM 221. Web Design I. IDM 221: Web Authoring I 1

Javascript Hierarchy Objects Object Properties Methods Event Handlers. onload onunload onblur onfocus

Font classification review

text++ Joi Anderson - jna2123 // Manager + Tester Klarizsa Padilla - ksp2127 // Language Guru Maria Javier - mj2729 // System Architect + Tester

Alphabet. elemental visual signs 26 characters frozen sounds

L A TEX for Psychological Researchers

Font Basics. Descender. Serif. With strokes on the extremities of the letters. T Script. Sans-Serif. No strokes on the end of the letters

c122jan2714.notebook January 27, 2014

Linotype Univers CD for Mac and PC - containing 63 font weights

My Mathematical Thesis

Unit 3--Alignment, Formatting Font--Size, Color, Style [Bold, Italic, and Underline] Block

RECOMMENDATION FOR THE AUTHORING OF PATENT APPLICATIONS FOR THE PURPOSE OF FACILITATING OPTICAL CHARACTER RECOGNITION (OCR)

UNIVERSITI TEKNOLOGI MALAYSIA TEST 1 SEMESTER II 2012/2013

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

Putting type on a page without incorporating typographic principles is merely word processing. Terry Rydberg, Author Exploring InDesign 3

Designing and Creating an Academic Poster using PowerPoint

City of Peterborough Guide to Accessible Documents A O D A

LaTeX and fonts. TrueType is built into most Windows/MacOS systems. PostScript Type 1 fonts are well-established and supported directly by

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Package fontquiver. February 1, 2017

Multimedia for the Web: Creating Digital Excitement. Multimedia Element Text

WORLD INTELLECTUAL PROPERTY ORGANIZATION GENEVA STANDING COMMITTEE ON INFORMATION TECHNOLOGIES STANDARDS AND DOCUMENTATION WORKING GROUP

fonts Some famous (and infamous) fonts

European Computer Modern font with oldstyle digits

TYPE ANATOMY jtittle

Transcription:

Fonts for Displaying Program Code in L A TEX Adrian P. Robson nepsweb.co.uk 6 June 2018 1 Introduction Here we look at fonts for printing program code in L A TEX documents. Suitable fonts are monospaced; have good glyphs for the special character used in program code; and have no confusing similarities between character glyphs. The fonts must also be simple to set as the default typewriter font, so they are easy to use in L A TEX verbatim environments. The following discussion is based on the typewriter fonts listed in The L A TEX Font Catalogue (www.tug.dk/fontcatalogue), and the examples work with MikTex and TeXlive installations. 2 Monospaced Fonts The following are the monospaced fonts that are easily available and can be simply used in verbatim environments. They are shown here at their normal size, with the upquotes package. Computer Modern Typewriter Latin Modern Typewriter TXTT Bera Mono 1

DejaVu Sans Mono Courier TeX Gyre Cursor KP Monospaced 1234567890 (a){a[a] -+ * / %^ =<>!& ~ ;:_#@$ " LuxiMono Inconsolata 3 Computer and Latin Modern Fonts The Computer Modern Fonts are the L A TEX default, so no action is needed to use its typewriter family. It is generally very good for program listings, but its tilde is too high and its minus too low, as this shows: +-~x. It has a plain zero. The Latin Modern family of fonts is almost the same as Computer Modern but its typewriter font has a lower tilde and higher minus: +-~x. 3.1 Using Latin Modern Typewriter If the Latin Modern Typewriter font is wanted, it is best to adopt the whole family with \usepackage{lmodern 4 TXTT Font This font is similar to Computer Modern, but it is generally a little bolder, and has a single story g glyph. It has a centrally aligned tilde ~ and a crossed zero 0. However, its asterisk glyph * is poor and set too high. To use it, simply make TXTT the default typewriter font: \renewcommand{\ttdefault{txtt 2

5 Bera and DejaVu Fonts Bera Mono and DejaVu Sans Mono fonts are almost identical 1 at the same scale, but the DejaVu asterisk glyph * is higher than Bera s *. At default scale values, DejaVu is slightly larger than Bera. The fonts are sans serif. They have a single story g glyph, a centrally aligned tilde ~, and a dotted zero 0. 5.1 Using Bera Mono To use Bera Mono as the default typewriter font, put the following in the preamble: \usepackage[scaled]{beramono If only occasional use of the font is needed then put this is the preamble after the main font families have been selected: \edef\oldtt{\ttdefault \usepackage[scaled]{beramono \renewcommand{\ttdefault{\oldtt \newcommand{\bera[1]{{\fontfamily{fvm\selectfont #1 This retains the existing typewriter font, and allows the following to to used to invoke Bera when needed: \bera{xdf-hju-0d4-s2e 5.2 Using DejaVu Sans Mono To use DejaVu Sans Mono as the default typewriter font, put the following in the preamble: \usepackage[scaled]{dejavusansmono 6 Courier and TeX Gyre Cursor Fonts Courier and TeX Gyre Cursor are almost identical 2, but the Courier asterisk glyph * is lower than Gyre s *. The fonts are lighter and larger than Computer Modern. They have a single story g glyph, a centrally aligned tilde ~, and a plain zero. 6.1 Using Courier To use Courier as the default typewriter font, put the following in the preamble: \usepackage{courier 1 DejaVu and Bera fonts are both derived from the Bitstream Vera fonts. 2 The font that is actually provided for Courier is URW Nimbus Mono. The TeX Gyre Cursor font is an enhanced version of this. 3

6.2 Using TeX Gyre Cursor To use TeX Gyre Cursor as the default typewriter font, put the following in the preamble: \usepackage{tgcursor 7 KP Monospaced KP Monospaced is sans serif with a plain zero. Its special characters are well balanced: * +-~x, but its zero and capital O are very similar: 0O. It is part of a font family with roman, sans-serif and monospaced shapes. 3 To adopt just its monospaced font, include this in the document preamble: \renewcommand{\ttdefault{jkptt 8 LuxiMono LuxiMono is a rather heavy and large serif font with a plain zero. Its special characters are well balanced: * +-~x, but its zero and capital O glyphs are very similar: 0O. To use it as the default typewriter font, put the following in the document s preamble: \renewcommand{\ttdefault{ul9 9 Inconsolata Font This is a sanserif programming font with a slashed zero. Its special characters (*+-~x) are will balanced apart from the tilde, which is a little too high. The alpha l and numeric 1 characters differentiated. The Inconsolata font can be made the default typewriter font with \usepackage{inconsolata or it can be invoked explicitly with \newcommand{\textincon[1]{% {\fontfamily{zi4\selectfont #1... \textincon{this is Inconsolata text 3 The KP Fonts Serif family of fonts is based on the URW Palladio fonts. The mathematics fonts include all the AMS fonts, in both normal and bold weights. 4

10 Conclusions and Recommendations We can reach the following conclusions: Do not use TXTT for program code because of its bad asterisk. However, its crossed zero can work well for passwords and the like. Do not use KP Monospaced because its zero and upper case O are too similar. Do not use LuxiMono because its zero and upper case O are too similar. Do not use Inconsolata because its tilde character is too high. Use Latin Modern instead of Computer Modern because its minus and title are better aligned. Use Bera Mono instead of DejaVu Sans Mono because it has a better asterisk. Use Courier instead of TeX Gyre Cursor because it has a better asterisk. In summary, for program code in L A TEX documents: Marked Zero: Bera Mono Plain Zero: Latin Modern Typewriter or Courier Which of these plain zero fonts is best is mainly a matter of taste. But if the general font family would have been Computer Modern, then Latin Modern Typewriter is an obvious choice. A Name Comparison Computer Modern count01 alldone MAX_VALUE Latin Modern count01 alldone MAX_VALUE TXTT count01 alldone MAX_VALUE Bera Mono count01 alldone MAX_VALUE KP Monospaced count01 alldone MAX_VALUE Courier count01 alldone MAX_VALUE TeX Gyre Cursor count01 alldone MAX_VALUE LuxiMono count01 alldone MAX_VALUE Inconsolata count01 alldone MAX_VALUE 5

B Symbol Comparison Computer Modern x~+-*/% -><=!& ^ apr@neps.co.uk Latin Modern x~+-*/% -><=!& ^ apr@neps.co.uk TXTT x~+-*/% -><=!& ^ apr@neps.co.uk Bera Mono x~+-*/% -><=!& ^ apr@neps.co.uk DejaVu Sans Mono x~+-*/% -><=!& ^ apr@neps.co.uk KP Monospaced x~+- * /% -><=!& ^ apr@neps.co.uk Courier x~+-*/% -><=!& ^ apr@neps.co.uk TeX Gyre Cursor x~+-*/% -><=!& ^ apr@neps.co.uk LuxiMono x~+-*/% -><=!& ^ apr@neps.co.uk Inconsolata x~+-*/% -><=!& ^ apr@neps.co.uk C Confusable Characters Computer Modern Teletype Z2 li1 S5 O0 TXTT Z2 li1 S5 O0 Bera Mono Z2 li1 S5 O0 KP Monospaced Z2 li1 S5 O0 Courier Z2 li1 S5 O0 LuxiMono Z2 li1 S5 O0 Inconsolata Z2 li1 S5 O0 D Sample Code D.1 Latin Modern Typewriter /* This does not make algorithmic sense, but it shows off * significant programming characters. */ #include<stdio.h> void myfunction( int input, float* output ) { switch ( array[i] ) { case 1: // This is silly code if ( a >= 0 b <= 3 && c!= x ) *output += 0.005 + 20050; char = g ; b = 2^n + ~right_size - leftsize * MAX_SIZE; c = (--aaa + &daa) / (bbb++ - ccc % 2 ); strcpy(a,"hello $@?"); count = ~mask 0x00FF00AA; 6

D.2 Bera Mono /* This does not make algorithmic sense, but it shows off * significant programming characters. */ #include<stdio.h> void myfunction( int input, float* output ) { switch ( array[i] ) { case 1: // This is silly code if ( a >= 0 b <= 3 && c!= x ) *output += 0.005 + 20050; char = g ; b = 2^n + ~right_size - leftsize * MAX_SIZE; c = (--aaa + &daa) / (bbb++ - ccc % 2 ); strcpy(a,"hello $@?"); count = ~mask 0x00FF00AA; D.3 Courier /* This does not make algorithmic sense, but it shows off * significant programming characters. */ #include<stdio.h> void myfunction( int input, float* output ) { switch ( array[i] ) { case 1: // This is silly code if ( a >= 0 b <= 3 && c!= x ) *output += 0.005 + 20050; char = g ; b = 2^n + ~right_size - leftsize * MAX_SIZE; c = (--aaa + &daa) / (bbb++ - ccc % 2 ); strcpy(a,"hello $@?"); count = ~mask 0x00FF00AA; 7