Matthew Gilliard
Matthew Gilliard

Reputation: 9498

Emacs: Multiple fonts in a single buffer

I use org-mode daily for all sorts of things, and I like variable-width fonts for reading text which makes up the majority of my files. But for tables to be correctly aligned, a fixed-width font it necessary. Is it possible to configure emacs to show org-mode tables in a fixed-with font and the rest of the buffer in a variable-width font?

I understand the typical question is not: "Is X possible in emacs?" but rather "How do I do X in emacs?" so I'm optimistic, but haven't found an answer on Google or SO yet...

Upvotes: 7

Views: 2280

Answers (2)

Daniel
Daniel

Reputation: 12026

For a more current solution you can check out mixed-pitch mode. It takes care of adjusting fonts not only tables and src-blocks in org-mode but also takes care of fonts in other text modes as well (LaTeX mode, for example).

Upvotes: 0

juanleon
juanleon

Reputation: 9380

You can have multiple fonts in a buffer (C-h C-a to see an example).

You can customize the font family of any face in emacs, so you can have variable and fixed width sizes fonts.

Then you can use font-lock-add-keywords (for example) in org-mode-hook to instruct font-lock to use a face with fixed width the regular expression that matches rows of a table (I think it would be something like "\s*|.*", but maybe I am oversimplifying)

Upvotes: 5

Related Questions