9

I've had this right at one point in the past on one machine with a certain font type at a particular font size, but I can't seem to get it right again.

Look e.g. at how my org mode tables look once I add Japanese characters. Here are two examples using fonts that were supposed to align properly (I read somewhere).

DejaVu Sans Mono Book 10

Insolata Medium 10

Help!

This is version

GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5) of 2014-12-10 on gaia, modified by Debian

Edit A copy-and-pasteable version of a bunch of alignment problems for anyone who wants to try themselves:

| a 漢字       |   |
| b はどう     |   |
| f デショウ a |   |
| ハーフ          |   |
| whole   |   |
| half         |   |
| ○            |   |

2 Answers 2

3

There's a solution that may be the best one currently (I use this solution):

http://coldnew.github.io/blog/2013/11/16_d2f3a.html

Though the article is in Chinese, but you still can read the Emacs Lisp code easily to understand what mechanism it has done.

My configuration example may be helpful.

2
  • Thanks, kuanyui. I haven't tried it yet, because I meanwhile figured out a simple (partial) solution. Is your emacs-font-size-pair-list perhaps addressing the font size issue that I describe in my answer? Apr 3, 2015 at 0:51
  • I cannot sure. But the size-pair-list is based on try-and-error for the fonts you're using (may be need some adjusts by yourself). So each zoom scale would be suitable if you set properly.
    – kuanyui
    Apr 3, 2015 at 3:13
1

The solution turned out to be surprisingly easy. After adding

(set-default-font "Inconsolata-12")

to the end of my ~/.emacs, it kind of (see below for details) worked.

Emacs Inconsolata 12


The Full story:

After copy-and-pasting the table into LibreOffice I noticed that Inconsolata worked, whereas DejaVu Sans Mono does not - which depends, I suppose, on my xorg font substitution settings. (My LibreOffice font substitution settings are empty.) To wit:

LibreOffice rendering of org-table format

That lead me to just play around with Inconsolata in emacs a little more, and to the set-default-font solution mentioned above.

Not all font sizes work however, and if I increase/decrease the font size, the alignment gets messed up again. Here are the results for the sizes I tried:

━━━━━━━━━━━
 size  ok? 
───────────
    6  ok  
    8      
   10      
   12  ok  
   14      
   16      
   18  ok  
   20      
   22  ok  
   24      
   26      
━━━━━━━━━━━

There is also one minor issue which I guess must be blamed on org-table, that is when I use the TAB key to navigate through cells, the formatting sometimes changes for the worse. The following is the result of pressing TAB in the leftmost cell:

TAB in org-table

Luckily though, a quick C-c C-c will repair the whole table again.

Edit Turns out there are still some characters that do not align properly. Neither in LibreOffice, nor in emacs. Example:

character: ○ (displayed as ○) (codepoint 9675, #o22713, #x25cb)

Corresponding screenshot:

some characters still don't align

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.