Mathsfont For Thought

Will Robertson

I have thought that Walden Pond would be a good place for business, not solely on account of the railroad and the ice trade; it offers advantages which it may not be good policy to divulge; it is a good port and a good foundation. Looking for Math fonts? Click to find the best 14 free fonts in the Math style. Every font is free to download!

[completed 2007-03-25]
Like many graduate students, Will Robertson hasgotten involved with TeX; he is also representative of a minority ofsuch TeX-using graduate students who take the next step of contributingsignificantly to the TeX community.

Data Simplification: Taming Information With Open Source Tools, Data scientists should familiarize themselves with LaTeX formula notation. The following short python script takes the sample size formula, in ascii notation, Before Python 3.6, you had two main ways of embedding Python expressions inside string literals for formatting:%-formatting and str.format.

Dave Walden, interviewer: Please tell me a bit about your personal historyindependent of TeX.

Will Robertson, interviewee: Turning 26 this year, I'm not old enough yet to have a personalhistory. I can tell you who I am, however. I am currently in the secondphase of my PhD in Mechanical/Mechatronic Engineering, for which I'm(approximately) trying to build a table that floats on magnets. Mycurrent plans are to finish up in about a year, but we'll see how thatgoes.

I'm living and have always lived (but most probably won'talways live) in Adelaide, in South Australia. We have apparentlythe greatest number of serial killers (or is it murders?) percapita in the world. We have the second largest Fringe Festival (arts,theatre, dance, and so on) in the world, a statistic I can't reallycomprehend given our size. It certainly transforms the city for almost amonth of every year, which is just starting up as we speak. Outside thecity, we've got a fantastic wine industry. Hopefully it remainssustainable while we run out of water.

I also work at a Chocolate Cafe, which keeps me busy when I'm notresearching. While it helps pay the bills, I mostly do it for the sidebenefits: access to lots of great chocolate and people. Although I'mbiased, we serve the best hot chocolate I've ever had: we use actualmelted Belgian chocolate, instead of chocolate powder or syrup, frothedup with steamed milk. And we can also make it with soy milk, to caterfor the vegans. Real chocolate doesn't have dairy in it, you see.

DW: How did you first get involved with TeX?

WR: My friend introduced me to TeX at the end of my third year ofuni (Mechatronic Engineering), which was around the end of 2001, Isuppose. I started out using LyX, and relatively quickly migrated toLaTeX proper. LyX is mostly fine if you don't know LaTeX and can livewithin its restrictions. Knowing LaTeX, I now find LyX rather clumsywhen I'm forced to help people in the department customise theirdocuments. Some of its features are quite convenient, though.

At first I was using LaTeX for technical purposes: reports and soon. It was the little things that we liked about it — ligatures,automatic numbering, sensible float and referencing behaviour, and soon. All this (except the better output quality) we could do with Word atthe time (provided you were very finicky when writing the document:“styles” provided the content/formatting separation we laud in LaTeX)but it was less effort in LaTeX. I don't know if that is still the case,but I'm very glad that Word is getting a proper maths renderer in Office2007 (we'll probably return to this point later in the interview). Atlast, mathematical documents produced in Word will be readable!

Anyway, after I started my PhD, I begun exploring the LaTeX worldin depth. Contrary to all of the recommendations, I actually found thatI didn't need a book to learn anything. Long hours exploring packagesand reading mailing lists sufficed. It took me a couple of years, Iguess, before starting to program with it proper, and now I can't reallygive it up. I no longer take my laptop to uni, in order to concentratemore on my work, so I don't have the opportunity to spend more than afew hours a week on LaTeX at the moment. That's good, else I'd neverget anything done.

DW: You mention helping people in your department. Please tellme a little more about this; for example, is there “official”support for TeX in your university?

WR: As for the usage of TeX that I see, I can only speak for what Iknow in my department, specifically, but I suspect it's probably asimilar situation for many other universities. In general, it seems thatmany people aren't very computer literate. This is a broad problem;people will do data analysis in Excel rather that a decent program likeMatlab; mathematics is still done by hand on paper rather than withMathematica (well, I guess this is more understandable; I think you needto “click” with Mathematica before it's very useful); Word is usedinstead of LaTeX.

However, not everyone uses Word. My PhD supervisor used LyX for histhesis, and he recommends it to all of the new PhD students. Anyone Ican influence uses LaTeX, because I tell them I can't (or won't) helpthem much if they use LyX. This is kind of true: some things I simplydon't think are possible within the LyX environment; my main excuse isgenerally that it's a pain to debug LyX when things go wrong from aLaTeX point of view.

Michael Murray, who is (or has been, when I was) active on theMacOSX TeX mailing list, is actually the Head of the maths departmentof our university. Over there, LaTeX is just what everyone uses. Whenyou're writing maths day-in, day-out, I guess it only makes sense.Mechanical Engineering doesn't follow their lead, but maybe ElectricalEngineering does.

As far as TeX support goes, as might be obvious to an observer,there is none. The university runs training courses in various Microsoftproducts, but that's as far as it goes. We have a very strong“pick it up as you go” culture in the software world (as I seethings generally), which means that software needs to be designed withthis in mind — able to be grasped non-committedly and coaxed toproduce something without too much effort. Bearing this in mind, LaTeXcan be a little difficult to approach (to say the least) for the casualuser.

Furthermore, where would TeX support come from? It would beunfeasible to suggest that TUG could provide any, and there aren't anyAustralian “LaTeX User Groups”, as far as I know. So people relyon the local expert, which is me — and eventually I teach themhow to use Google Groups to answer their questions, as they are usuallytrivial to solve.

DW: Do you have any contact with or awareness of TeX users inother universities such as Baden Hughes in Melbourne (who was a foundingmember of the The PracTeX Journal editorial board) or Ross Moore in Sydney (who is amember of the TUG board)?

WR: Like I said above, there is no Australian TeX user group that Iknow of, and so communication between “well-known” Australian TeXcelebrities only happens through happenstance. I didn't know that BadenHughes was from Melbourne, but Ross Moore and I have been working onsome XeTeX things together for a little while now (not that we'vemet — we're 1400km apart). We started collaboratingthrough XeTeX connections, however, so it's just coincidence that we'recompatriots.

DW: You and I first became acquainted through working onThe PracTeX Journal (The PracTeX Journal). How did that come about and what is yourmotivation for putting effort into this TUG activity?

WR: That's right. To be honest, I can't remember how I got ropedinto all that! The email conversation that initiated it seems to betemporarily lost in time (I'm sure it's somewhere in my mail), but Ivaguely remember offering a bunch of suggestions early on, and presumablyLance Carnes (Editor) thought that my opinions were along lines thatweren't well-represented with their then-members of the board. (That is,if I was just re-iterating opinions of the board, my help would havebeen less valuable.) Somehow he also recognised the opportunity to sharesome of the production burden, and I started “production editing”a couple of papers per issue almost immediately.

These days, we've got more helpers, and I've been less able tospend as much time. To be honest, I see the production work I do(sending off articles for review, reviewing articles myself, andcopy-editing others) as an enjoyable chore with the side-benefit oflearning a good amount about how (online, at least) journals work fromthe inside. As a hobby, there are much worse ways I could spend some ofmy time.

DW: Also, I see from the author index that you have writtenthree articles for The PracTeX Journal.

WR: I'm much happier writing the articles, but that takes alot more time. Like you say, I've written a few now, on a somewhatdiverse range of topics. My motivation for them comes from a fewsources. Firstly, I need to practise writing. I wouldn't say that I lovewriting, nor that I am “a writer” (although I wouldn't mind tryingit one day), but when I write well I enjoy it, and I can only writebetter with practise. (Whether I write “well” ever, anyway, iscertainly up for debate.) Most important, probably, is the aspect ofsharing knowledge around. The things I write about forThe PracTeX Journal aren't new or novel, they're just reporting facts andopinions — the journalism side of technical writing, I guess youcould say. When I spend time looking into, to use an example, thefeatures of the Latin Modern fonts, and many people still seem to beignorant of them, it only makes sense to write about it and make thetime I originally put in better spent. The LaTeX world is a bit of messdue to its age: there's a lot of useless stuff lying around in CTANthat should be retired but can't be for backwards compatibility. Tryingto teach people to use the current “best practise” seems a worthycause to me. That's the type of thing I can't really quantify,though. Lastly, to be egotistical, it's nice to see your name in print.

DW: My memory is that in addition to serving as a productioneditor, you took over maintenance of the LaTeX class for The PracTeX Journal.

WR: The pracjourn class was the first document class that Ipublished for people to actually use, I think, and really got the ballrolling for me in terms of getting used to the issues involved withthat. Formatting the frontmatter (name, affiliation, email address,etc.) was an interesting typesetting job, and I (still) thinkthe design I settled on works quite well. At least, I haven't tired ofit yet. I've never actually heard feedback from anyone whether they likeor even notice it, though.

DW: I think it functions well for its purpose.

WR: I've gone on to write fairly basic classes for a few conferencesthat I (or colleagues) have attended. I've been quite disappointed withthe quality of some of the ones I've come across that I haven't written;in some cases, the conference organisers have just coerced a poorgraduate student who might know how to write a LaTeX document intowriting the class. The results aren't pretty; the last one I saw hadinstructions to write sections something likeThat's right. Manual section numbering. Manualformatting. Not exactly what we're used to.

Word

Going a little off-topic, I think organising some sort ofTUG-organised, community-driven service for conference organisers tocreate one-off classes for conferences would be a decent thing to haveto ensure that this sort of thing doesn't happen in the future. Afterall, once you've written one conference class, there's not too much thatneeds changing to adapt it for new typesetting guidelines.

DW: Since you reached the point where you could “programwith it proper”, you have obviously gone a lot deeper into it than manyTeX users with only a few years experience. Can you give me a briefsketch of the purpose or function of fontspec, and how your developmentof it came about? I noticed you wrote an article for TUGboat about it:“Advanced font features with XeTeX — the fontspecpackage”.

WR: This answer needs a little bit of background. Bear with me whileI try to be brief. As we probably all know, TeX was invented beforecomputers were powerful and even before the notion of a “computerfont” was well established or at least standardised. So its methods fordealing with fonts have been very quaint for some time now.

In order to overcome the many limitations that TeX imposes on thefonts it can use (as well as the input of multilingual text), JonathanKew wrote the XeTeX program, an extension of TeX that accepts Unicodeinput and supports OpenType fonts. Unicode input is important to be ableto write in any desired language, and OpenType fonts areimportant to be able to typeset them.

To cut a long story short, the way XeTeX interfaces with OpenTypefonts is rather low-level. Font features such as using lowercase numbersinstead of uppercase numbers are activated with hard to remember stringssuch as +onum. The fontspec package provides a more readable (andhopefully memorable) interface to such things with keyval-type optionssuch as Numbers=Lowercase.

Secondly, LaTeX itself wasn't designed to accommodate the idea of“font features”, whereby a broad range of minor typographicaldetails could be varied between instances of any one font. (Only“macroscopic” variations, such as boldness or shape, are directlyprovided for.) The fontspec package allows users to select fonts withany combination of font features, and to change the font featuresmid-document.

But most importantly, fontspec simply allows users to select fontseasily. No need to mess around with extra files that need to bewritten, or swathes of font definition code. In its simplest form,setmainfont{Baskerville} is all that is required to selectBaskerville as the main document font.

DW: Do you have prior background/interest with fonts,typography, etc., or did your interest develop in parallel with yourexperience with TeX?

WR: I'd always been finicky about layouts and fonts, but it was TeXthat really brought out my major interest. Before XeTeX, I experimentedwith various fonts that could be installed in TeX, and before that Iwas experimenting with GUI fonts to a small degree. MacOSX is bundledwith a nice selection of interesting fonts, and I was fascinated withtwo in particular: Frere-Jones' Hoefler Text, with its wide range offont features such as swash caps, engraved caps, dedicatedsubscript/superscript characters, and so on (and so on!) — allwithin a single font — epitomised the abilities of modern fontsto provide for every last detail (in the limiting sense). Secondly,Hermann Zapf's Zapfino was the first script font that I'd used with alarge number of contextual ligatures and alternate characters. XeTeXallowed us access to these fonts within a LaTeX environment, the bestof both worlds.

DW: How did you get connected with the XeTeX system? Is yourfontspec work coordinated with a larger group of peopleworking on expanding the capabilities of XeTeX?

Mathsfont For Thought

WR: The MacOSX TeX mailing list is certainly what got me startedin my TeX hobby. It was there I began asking my naive beginnersquestions, and slowly learned enough to start answering others'. So fora couple of years, I was quite active there. But I realised eventuallythat I wasn't gaining anything by spending so much time reading andreplying there, and chose to leave. Only so much time in the day, andall that. But these days I browse the comp.text.tex newsgroup,which takes a similar amount of time. There's no escape, it seems.

Via the MacOSX TeX mailing list, we learnt about this new XeTeXproject in April 2004. I started using it a few months after that, butnot for any serious work. Even back then, my knowledge of TeX andLaTeX was that of a user; I didn't have any knowledge, less experience,of any actual programming in TeX. Over time, it became obvious to methat something needed to be done to make fonts easy to set up inXeLaTeX (that is, LaTeX when using the XeTeX engine). Bruno Voisinhad a template for setting up NFSS families in LaTeX withXeTeX-native fonts, but that method was a little inaccessible.

I played around for a while with various interfaces before creatingfontspec. You only learn from doing, and this was my first TeXprogramming project. At first, fontspec simply let you select a font touse immediately. Then to select the font for the whole document. Andthen to select font features as well. My old versions are lost in time(I didn't know version control back then; I've only started learning itwithin the last year!) but I remember the slow understandingof how TeX programming worked. Now, I'm a little more confident of myability to put a package together, and I'm working on a new package fordealing with Unicode maths. Jonathan has been putting in features tofollow Microsoft Word 2007's lead in OpenType maths font features, andI've taken up the project to provide the user interface for it all, muchin the same way as fontspec is a user interface for XeTeX's font accessin general. (It's a little bit embarrassing that the TeX community hasto follow the lead of Microsoft Word, of all programs, but oh well.)

Chris Rowley and Ross Moore are helping me out with various partsof this “Unicode maths” project, but there isn't a group of usworking together to improve XeTeX in general. Jonathan works onwhatever he feels motivated by, which rather recently has been toimprove the maths support of XeTeX after Microsoft gave him a model tofollow. Similarly, I do what I can with fontspec and a couple of minorpackages, and Ross has a “Unicode text” package that's beenessential for new users of XeTeX to have compatibility with their oldLaTeX documents. But we've never met, and we communicate mainly via theXeTeX mailing list.

It seems to work best this way, in the open source softwareworld — too many people working together gets everyone boggeddown trying to work collaboratively, rather than just heading off intheir own directions and seeing what happens.

DW: I assume you will use TeX to write your thesis. Do youthink you will stay with TeX after you graduate or drop it as so manyother graduate students do after having used it for the few years neededto write a thesis?

WR: I am quite surprised by this question. Of course I will staywith TeX! My interests have extended far beyond what I need to typesetmy thesis. I'm reasonably confident, however, that my office mates willhave a hard time sticking with LaTeX, even though they like it, becausethey only have me to ask when they run into problems. They don't knowwhere else to look.

This leads me into a few words about where I think the big problemsof LaTeX lie. Because it's obvious that it is much harder to learn thanit could be. And the crux of the problem, the long and the short of it,is that the LaTeX kernel has been intentionally restricted to thefunctionality originally designed for it. Now, this is a good thing, byand large. Standards need to be frozen in order for them to be adheredto. But it's past time to move on and create a new standard. There arefast approaching competitors that will eventually overtake LaTeX if wecontinue to stagnate. (Not to mention ConTeXt, which has surpassedLaTeX in essentially every area. Maybe the solution is just foreveryone to switch to that.)

As far as a document preparation system goes, LaTeX has a lot ofwork to catch up to what's happened over the last five years in HTML.Introductions to LaTeX often laud the separation of form and content inthe LaTeX syntax, but the implementation is only skin deep in comparison with the things that HTML+CSS can do.

Most of LaTeX's shortcomings are solved with various packages, andmany of those packages are so widespread now that their use isessentially mandatory. The memoir class attempts to unify many aspectsof document preparation, but even that noble effort cannot hope toaccommodate everything.

The LaTeX3 project is supposed to be working to update LaTeX. Butthey face another problem: they've invented a wonderful extension to theLaTeX programming language in order to do all of their coding. But nowthey're stuck with a system that no-one knows how to use, and no-onewill learn it to write their packages because no-one's using LaTeX3yet. On top of all that, LuaTeX is set to be released in a year or so,perhaps obviating all their hard work on the low-level design.

If I magically were able to make this all happen, here's a roughsketch of things I expect to see over the next few years to get LaTeXback on its feet. Who knows, this might be their plan anyway. In anycase, after I write my thesis I wouldn't mind helping out.

  • With the next release of LaTeX2e, the LaTeX3 team releases aformal LaTeX2e package that contains the designs of their LaTeX3syntax. This allows LaTeX2e package writers to update their thinking andtheir packages and, importantly, to learn the new system. Wrinkles inthe syntax can be ironed out with (hopefully) widespread use.
  • At around about the same time, “someone” (a single person orsmall group better than a committee) writes a high-level specificationof the LaTeX3 document preparation interface. In short, a formaldefinition of every document element from chapter heading to footnotethat could possibly be used within the large majority of documentswritten in LaTeX. Gather as much material from existing packages andclasses with the intention of unifying all of the best ideas of theLaTeX2e ecosystem into LaTeX3. For example, built-in support formulti-page tables, multiple levels of footnotes, named referencing ofdocument parts, and so on. This is just a design document, not thelow-level code.
  • Finally, the actual code is written. By now, we've got a syntax towrite code in, and a specification of what needs doing, plus enoughpeople that know the system who can help out. Port over as much aspossible from LaTeX2e, and LaTeX2.5 is released, theinterim unstable version of LaTeX that is backwards incompatible withLaTeX2e and that will converge eventually to LaTeX3, which will remainfixed for another ten years.
  • In 2030, repeat the process :).
Of course, talking is easier than doing. But the main theme here is“get people involved”. Very few people are going to learn theLaTeX3 syntax without something to gain from the process. As anacademic exercise its appeal is limited, but if the syntax can be usedto write LaTeX2e packages then I think its popularity will beassured. (Coming from a novice package writer, the new syntax is abreath of fresh air.)

So back to your question: yes, I'm looking forward to sticking withLaTeX and I'm enthusiastic about its long term future.

DW: I'll close this interview by saying: Thank you forparticipating in our interview series; it has been good to hear thepoint of view of a relatively short term user of TeX. Also, best wishesfor finishing your graduate work and your life and career after that. Ihope we will be able to meet in person at some point.

Interview pages regenerated January 26, 2017;

It is possible to have precise control over responsive typography. Using calc() and viewport units you can create fluid type that scales perfectly between specific pixel values, within a specific viewport range.

I don’t know why we don’t see viewport units being used more extensively for creating designs with responsive typography.

Viewport units have been around since 2012 and are fairly well supported. In fact Internet Explorer was an early mover on this and supports viewport units as far back as IE9.

They are also really easy to understand. One viewport unit is simply 1% of the viewport and there are 4 types of viewport units:

  • vw - viewport width,
  • vh - viewport height,
  • vmin - height or width, whichever is smaller,
  • vmax - height or width, whichever is larger

So the reason viewport units are not used more extensively is probably not due to a lack of browser support or developers' understanding. My guess is it’s probably more likely to do with the lack of precise control designers have over the font-size.

Designers that love typography often really love typography and they enjoy precise control over line-height, font-size, letter-spacing and other elements of typography those of us not in the club might not even know exist.

This desire for precise control is the reason that some designers still prefer to declare these properties using pixels. But it doesn’t really matter, whether they use ems, rems or percentages the truth is, they are all just abstractions of a base font size and that is usually 16 pixels. So they have never really had to give up complete control. It’s not difficult to work out what font-size an element is, as long as we know the base font-size.

Thought

But viewport units are different! They represent a fundamental change in approach. Unlike all the other units, viewport units are not relative to the base font size in any way. Instead they are relative to the viewport, which the user controls, and that might be scary for some.

But there are advantages to using viewport units, a font-size declared with viewport units is fluid, meaning it will scale smoothly. This is a clearly a better experience than clunky responsive typography techniques that require multiple media queries.

Responsive typography with viewport units is really easy to implement, just declare the base font-size using vw; as long as you are not using pixels elsewhere in your stylesheet, other units are relative to the base font-size, (which is now viewport units) so they will all scale accordingly.

But there are a few rough edges you will need to sand back. Firstly when you get down to a very small viewport scaling is problematic. Luckily there are a few good methods for avoiding this.

Limit font scaling with calc() permalink

If you would like set an exact minimum font-size in pixels you can use calc().

This example says set the default size to 16px + 3vw.

Note: There are still issues in some browsers when using viewport units and calc() together, so for now media queries is probably safer.

Limit font scaling with media queries permalink

Mathsfont For Thought Process

You can prevent the text from scaling below a specific threshold simply by using a media query and only applying viewport units above a certain device resolution.

We can also stop scaling above a specific font-size, but for this we need to first work out what the viewport size will be at the font-size we want to stop scaling. For that we need a bit of maths:

With that result just set another media query to change the root font-size back to a fixed unit.

The calculations are not that hard but I find it easier to look at a simple table. This helps me visualise the change in font-size across different resolutions.

Viewport units:1vw2vw3vw4vw5vw
Viewport sizefont-size in pixels
400px4px8px12px16px20px
500px5px10px15px20px25px
600px6px12px18px24px30px
700px7px14px21px28px35px
800px8px16px24px32px40px
900px9px18px27px36px45px
1000px10px20px30px40px50px

Looking at the table you can see there are many limitations. We have little control over the rate at which viewport units change and we are confined to the options available in the table.

Precise control with calc() permalink

In his 2012 article on Fluid Type Trent Walton said:

'It's been hard to let go of setting a static font-size for a site and calling things done. I’m realizing that the predictability & control we've had over web type is becoming a thing of the past.'

But perhaps not all predictability and control is lost.

Let's imagine that as a typography nerd with an eye for absolute precision, you want the font-size at a resolution of 600px to be 12px. Great! Looking at the table, setting a font-size of 2vw will achieve this. But you also want the font-size at 800px to be 32px. It seems you can’t do this without changing from 2vw to 4vw and this means a break-point and our font scaling will be jumpy and not fluid. I consider this a pretty significant limitation.

There is a solution to this! It's not exactly pretty but it works – at least in modern browsers. As stated earlier, some browser have bugs when using calc() and viewport units together, so this might be buggy in some older browsers. (This is not really a concern anymore, just set sensible default font sizes before declaring a fluid type calc() expression.)

It appears that by using calc() and vw we can get responsive typography that scales perfectly between specific pixel values within a specific viewport range.

This means you can have perfect smooth scaling between any 2 font sizes over any viewport range. The font will start scaling and stop scaling exactly where you want.

Try the demo: Precise control over responsive typography The demo uses SASS so you can easily change the upper and lower limits of the font-size and media queries. But the important part looks something like this:

Thought

Note: In the example above, 12px is the minimum font-size and 24px is the maximum. 400px is the start of the viewport range and 800px is where it should stop scaling. The inclusion or absence of the units after each value is important.

Put simply, it is a function that takes a value within a range and works out what the new value would be if applied to a different range. I can take the current viewport width (100vw) as input into this ‘function’. For example if I had viewport range of 500px to 1000px, and let’s imagine the current viewport is 750px, I then apply this to a font-size range. If my font-size range was 20px to 30px, because the input of 750px is right in the middle of 500px and 1000px my new font-size will also be right in the middle, 25px. Simple right?

This seems like it could be a pretty useful way to control the scaling of viewport units. It could also have uses beyond typography. You can do other interesting things, by inverting the range for example, you can have font sizes that get smaller as the viewport gets larger. Perhaps there is a use for this? I’d love to hear your thoughts and see other applications or extensions of this idea.

Update: Each of the methods above use pixels for 'precise' control, however some readers have expressed concern that this will override user preferences for default font size. This is true, however all methods also work equally well with rem or any other unit type.

More info permalink

Math Fonts For Windows

  • Fluid Type, Trent Walton
  • Viewport units, Tim Severien
  • CSS Viewport Units, Chris Mills
  • FitText, Dave Rupert
  • Viewport sized typography, a similar concept by Eduardo Bouças
Comments are closed.