3

Running Emacs 27.2 on Windows 10.

My Org mode table is misaligned when I use (add-hook 'org-mode-hook 'variable-pitch-mode) (see the code below). Yes, my fonts are applied but the table is misaligned. If I delete the (add-hook 'org-mode-hook 'variable-pitch-mode) my table is well aligned but my font is gone. Therefore, I was wondering if there is a way to keep my font but keep my table aligned? Does my problem come from the font I used (Fira Code Retina)? I tried adding a hook removing the variable-pitch-mode for orgtbl-mode-hook but it did not work. I am quite new using Emacs; I am planning to use it for Latex and some coding.

(custom-theme-set-faces
       'user
       '(variable-pitch ((t (:family "Fira Code Retina" :height 180 :weight thin))))
       '(fixed-pitch ((t ( :family "Fira Code Retina" :height 160)))))
        
        (add-hook 'org-mode-hook 'variable-pitch-mode)

Answer: I solved it: I completely forgot the next line.

(set-face-attribute 'org-table nil  :inherit 'fixed-pitch)

Now everything works.

6
  • 1
    You can answer your own question. Please add your edit as an answer! You can then accept your own answer, and your question will be moved from the 'unanswered' to the 'answered' sections.
    – Tyler
    Feb 4 at 16:40
  • @Tyler thanks for letting me know, however when i click in edit there is not option to add answer my own question. Look at the beginning when i wrote the question, the option answer my own question was available but i did not took it into account. therefore, how can i set it answered?
    – baezacaljo
    Feb 5 at 0:55
  • 1
    @baezacaljo not when you click edit, just when you view this question.
    – mooseface
    Feb 5 at 11:48
  • 1
    @baezacaljo After you've posted your question, you can add an answer by entering your answer in the "Answer" box at the bottom of the page. You don't need to use the "answer my own question" option (which isn't available anymore).
    – Tyler
    Feb 7 at 14:36
  • @mooseface Thank you very much, i already did it.
    – baezacaljo
    Feb 7 at 18:09

2 Answers 2

3

Just add the following line

(set-face-attribute 'org-table nil  :inherit 'fixed-pitch)

Also in change the 'user for 'leuven-dark (this is an example but it could be another theme). see code bellow

(custom-theme-set-faces
       'leuven-dark
       '(variable-pitch ((t (:family "Fira Code Retina" :height 180 :weight thin))))
       '(fixed-pitch ((t ( :family "Fira Code Retina" :height 160)))))
        
        (add-hook 'org-mode-hook 'variable-pitch-mode)
0

Another possibility, if you still want variable pitch text while still keeping the tables aligned is using package Valign, which aligns tables in Org mode and markdown mode by pixel lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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