unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* latex mode, nexted subscripts are unreadable
@ 2007-09-06 23:21 Tim Hesterberg
  0 siblings, 0 replies; 9+ messages in thread
From: Tim Hesterberg @ 2007-09-06 23:21 UTC (permalink / raw)
  To: bug-gnu-emacs

I'm using latex mode, with font-lock on.
describe-mode shows:
Enabled minor modes: Auto-Compression Blink-Cursor Column-Number
Display-Time Encoded-Kbd File-Name-Shadow Font-Lock Global-Font-Lock
Line-Number Menu-Bar Mouse-Wheel Shell-Dirtrack Show-Paren Tooltip
Unify-8859-On-Encoding Utf-Translate-Cjk

I have equations like this:
\begin{equation}
  \sum_{i=1}^n (y_i - \sum_{j=1}^p\sum_{k=1}^{p_j} X_{i,j_k}\beta_{j_k})^2
  + \theta \sum_{j=1}^p (\sum_{k=1}^{p_j} \beta_{j_k}^{\gamma_j})^{\frac{\gamma_0}{\gamma_j}},
\end{equation}

Note that there are nested combinations of subscripts and superscripts.

In Emacs 21.1 in latex mode, subscripts and superscripts are shown
with smaller fonts, and raised or lowered.  Cool!  This is great for
first-level suscripts.  However nested superscripts and subscripts are
(1) very tiny and (2) shown in gray, rather than the same color used
for the first-level suscripts.

I use emacs in reverse video  (I use -r on startup).
The gray is nearly invisible against the black background.
Most of the pixels are a dark gray; a few are a lighter gray.

If I view the same file without reverse video, and start with
 --no-init-file, then the nested suscripts are visible, but are still
too tiny for comfort.  And they're not clearly visible - the gray letters
end up with most of the pixels light gray and a few of them darker.

My default font is Courier New, Regular, 10.
If I change the default font size to 11, 12, or 14, then the nested suscripts
are the same color as the first-level.  Changing to 8 or 9 is similar to 10.
Changing to 7 makes the first-level suscripts gray and nearly
invisible.  Changing to 6 makes all the text gray and nearly invisible,
When I do mouse-set-font, 8 is the smallest size that shows up.
So I suspect that the problem is that emacs is trying to use
font size 6 or smaller for nested suscripts, and that rescaling to give
that font size gives bad results.

Is there a way to set a minimum font size for suscripts?

Thank you,
Tim Hesterberg


In GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600)
 of 2007-06-02 on RELEASE
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --cflags -Ic:/gnuwin32/include'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

Major mode: LaTeX

Minor modes in effect:
  display-time-mode: t
  shell-dirtrack-mode: t
  show-paren-mode: t
  encoded-kbd-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t

Recent input:
<help-echo> <switch-frame> <help-echo> . <return> I 
f SPC I SPC v i e w SPC t h e SPC s a m e SPC f i l 
e SPC i n SPC <escape> h w i t h o u t SPC r e v e 
r s e SPC v i d e o , SPC <down-mouse-1> <mouse-movement> 
<mouse-movement> <mouse-1> C-p C-e a n d SPC s t a 
r t SPC w i t h <return> C-y , SPC t h e n SPC t h 
e SPC n e s t e d SPC s u s c r i p t s SPC a r e SPC 
v i s i b l e , SPC b u t SPC s t i l l SPC t o o <return> 
t i n y SPC f o r SPC c o m f o r t . C-p C-e <escape> 
b <escape> b <escape> b C-b C-b SPC ( t h o u g h SPC 
s t i l l <return> d o n ' t SPC s t a n d SPC o u 
t SPC w e l l ) C-p C-e <escape> b <escape> b C-n SPC 
C-d C-u C-p C-n C-e C-o C-o <return> R e a l l y SPC 
n e a r l y SPC i n v i s i b l e C-a C-k C-k C-k C-n 
C-n C-n C-n C-n C-SPC C-n C-n C-n C-p C-w C-SPC C-SPC 
<escape> < <escape> w C-x k <return> C-x 4 b t e m 
p 5 <return> C-y C-x n C-SPC <escape> f <escape> f 
<escape> f <escape> w C-x N <escape> x e m a c s - 
r e p o r C-a C-y C-k <return>

Recent messages:
Type C-x 1 to remove help window.  
Auto-saving...done
Mark set [2 times]
Auto-saving...done
Mark set
Auto-saving...done
Mark set [2 times]
Mark activated
Transient-mark-mode temporarily enabled
Mark set [2 times]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: latex mode, nexted subscripts are unreadable
@ 2007-09-12 18:12 Karl Berry
  2007-09-12 22:34 ` Jason Rumney
  2007-09-12 23:40 ` Tim Hesterberg
  0 siblings, 2 replies; 9+ messages in thread
From: Karl Berry @ 2007-09-12 18:12 UTC (permalink / raw)
  To: timh; +Cc: bug-gnu-emacs

Hi Tim,

Thanks for the report.

    the nested suscripts are visible, but are still too tiny for comfort.
    And they're not clearly visible - the gray letters end up with most of
    the pixels light gray and a few of them darker.

Unfortunately neither I nor Juri were able to reproduce this on our
(non-Windows) systems.  

Is there an Emacs developer who works on Windows who could look into this?

    Is there a way to set a minimum font size for suscripts?

Looking at tex-mode.el, it seems that faces named `subscript' and
`superscript' are used for this.  By default, they are defined like this
(both are just the same except for the name):

    (defface subscript
      '((t :height 0.8)) ;; :raise -0.3
      "Face used for subscripts."
      :group 'tex)

The :height is presumably what makes it proportional to the next "level"
up.  So perhaps it would work to override these definitions by changing
those faces -- using customize is probably easiest -- to use an absolute
font size.

Best,
Karl




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: latex mode, nexted subscripts are unreadable
  2007-09-12 18:12 Karl Berry
@ 2007-09-12 22:34 ` Jason Rumney
  2007-09-13  0:48   ` Tim Hesterberg
  2007-09-26  7:41   ` Glenn Morris
  2007-09-12 23:40 ` Tim Hesterberg
  1 sibling, 2 replies; 9+ messages in thread
From: Jason Rumney @ 2007-09-12 22:34 UTC (permalink / raw)
  To: Karl Berry; +Cc: bug-gnu-emacs, timh

Karl Berry wrote:
> Hi Tim,
>
> Thanks for the report.
>
>     the nested suscripts are visible, but are still too tiny for comfort.
>     And they're not clearly visible - the gray letters end up with most of
>     the pixels light gray and a few of them darker.
>
> Unfortunately neither I nor Juri were able to reproduce this on our
> (non-Windows) systems.  
>
> Is there an Emacs developer who works on Windows who could look into this?
>   

It depends on the font used and the antialiasing settings of the system.
I imagine you could reproduce it on X in the emacs-unicode-2 branch with
the xft font backend enabled, some tinkering with /etc/fonts/fonts.conf
(or whatever the fontconfig configuration file is on your system) and
Courier New or a similar poorly designed truetype font.

I can only reproduce the problem with Courier New and "standard"
antialiasing. Switching to Bitstream Vera Sans Mono, or changing to
"Cleartype" sub-pixel antialiasing (on and LCD screen) both make the
problem disappear.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: latex mode, nexted subscripts are unreadable
  2007-09-12 18:12 Karl Berry
  2007-09-12 22:34 ` Jason Rumney
@ 2007-09-12 23:40 ` Tim Hesterberg
  2007-09-14  0:24   ` Karl Berry
  1 sibling, 1 reply; 9+ messages in thread
From: Tim Hesterberg @ 2007-09-12 23:40 UTC (permalink / raw)
  To: Karl Berry; +Cc: bug-gnu-emacs

Karl,

Thanks for looking into this, and for the suggestion of customizing
the faces.

I tried customizing the superscript and subscript fonts, in two
different ways:
  menu:   Options : Customize Emacs : Specific Face
  modify-face
I could change the height to 80 (i.e. 8 point font).
This results in nested suscripts being the same size as the
first-level suscripts, and so prevents the problem with fonts
being too small.

However, the raising and lowering was messed up.  Now
$a_{b^c}$ makes $c$ elevated at the same level as the $c$ in $a^c$;
the raising is done relative to $a$ rather than to $b$.
Maybe this is a separate bug?

I also tried a relative value of 0.9.  This resulted in smaller
size changes, and fonts did not become unreadable until 5th level.
However, this also leaves the raising and lowering messed up.

I tried evaluating a modified defface definition  (in a temporary file,
not by changing tex-mode.el) but this had no effect.

Tim

>Hi Tim,
>
>Thanks for the report.
>
>    the nested suscripts are visible, but are still too tiny for comfort.
>    And they're not clearly visible - the gray letters end up with most of
>    the pixels light gray and a few of them darker.
>
>Unfortunately neither I nor Juri were able to reproduce this on our
>(non-Windows) systems.  
>
>Is there an Emacs developer who works on Windows who could look into this?
>
>    Is there a way to set a minimum font size for suscripts?
>
>Looking at tex-mode.el, it seems that faces named `subscript' and
>`superscript' are used for this.  By default, they are defined like this
>(both are just the same except for the name):
>
>    (defface subscript
>      '((t :height 0.8)) ;; :raise -0.3
>      "Face used for subscripts."
>      :group 'tex)
>
>The :height is presumably what makes it proportional to the next "level"
>up.  So perhaps it would work to override these definitions by changing
>those faces -- using customize is probably easiest -- to use an absolute
>font size.
>
>Best,
>Karl




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: latex mode, nexted subscripts are unreadable
  2007-09-12 22:34 ` Jason Rumney
@ 2007-09-13  0:48   ` Tim Hesterberg
  2007-09-13 15:03     ` Drew Adams
  2007-09-26  7:41   ` Glenn Morris
  1 sibling, 1 reply; 9+ messages in thread
From: Tim Hesterberg @ 2007-09-13  0:48 UTC (permalink / raw)
  To: Jason Rumney; +Cc: bug-gnu-emacs, Karl Berry

Jason provided some additional information privately:
>The Bitstream Vera family of fonts can be downloaded from
>http://www.gnome.org/fonts/
>
>Cleartype is only an option in Windows XP and later, and generally only
>looks good on (most) LCD monitors, due to assumptions it makes about the
>layout of colors within the pixel.
>
>To switch it on, open the Display control panel, go to the Appearances
>tab and click "Effects..." It should be in the dropdown selection on the
>second option from the top.

He also suggesting using Lucida Console instead of Courier New.

ClearType does fix the nested suscript problem (with Courier New),
but makes me feel like I'm on acid - my white text gets pink and
blue hues.  I'll try his other solutions.

Jason Rumney <jasonr@gnu.org> wrote:
>Karl Berry wrote:
>> Hi Tim,
>>
>> Thanks for the report.
>>
>>     the nested suscripts are visible, but are still too tiny for comfort.
>>     And they're not clearly visible - the gray letters end up with most of
>>     the pixels light gray and a few of them darker.
>>
>> Unfortunately neither I nor Juri were able to reproduce this on our
>> (non-Windows) systems.  
>>
>> Is there an Emacs developer who works on Windows who could look into this?
>>   
>
>It depends on the font used and the antialiasing settings of the system.
>I imagine you could reproduce it on X in the emacs-unicode-2 branch with
>the xft font backend enabled, some tinkering with /etc/fonts/fonts.conf
>(or whatever the fontconfig configuration file is on your system) and
>Courier New or a similar poorly designed truetype font.
>
>I can only reproduce the problem with Courier New and "standard"
>antialiasing. Switching to Bitstream Vera Sans Mono, or changing to
>"Cleartype" sub-pixel antialiasing (on and LCD screen) both make the
>problem disappear.
>




^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: latex mode, nexted subscripts are unreadable
  2007-09-13  0:48   ` Tim Hesterberg
@ 2007-09-13 15:03     ` Drew Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2007-09-13 15:03 UTC (permalink / raw)
  To: Tim Hesterberg, Jason Rumney; +Cc: bug-gnu-emacs, Karl Berry

> ClearType does fix the nested suscript problem (with Courier New),
> but makes me feel like I'm on acid - my white text gets pink and
> blue hues.  I'll try his other solutions.

ClearType can require some tunining for color-shift problems. I recommend
this free tool, which lets you tune it:

Wikipedia article: http://en.wikipedia.org/wiki/ClearType
Download the tuner:
http://www.microsoft.com/typography/ClearTypePowerToy.mspx

HTH - Drew





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: latex mode, nexted subscripts are unreadable
  2007-09-12 23:40 ` Tim Hesterberg
@ 2007-09-14  0:24   ` Karl Berry
  2007-09-14 16:47     ` Tim Hesterberg
  0 siblings, 1 reply; 9+ messages in thread
From: Karl Berry @ 2007-09-14  0:24 UTC (permalink / raw)
  To: timh; +Cc: bug-gnu-emacs

    I tried evaluating a modified defface definition  (in a temporary file,
    not by changing tex-mode.el) but this had no effect.

I believe that defface is like defvar et al; if the symbol is already
defined, it won't do anything.  You can call modify-face or
set-face-attribute from Elisp to change existing faces.
    
    $a_{b^c}$ makes $c$ elevated at the same level as the $c$ in $a^c$;
    the raising is done relative to $a$ rather than to $b$.
    Maybe this is a separate bug?

Maybe.  I believe this is the code in tex-mode.el that does the raising
and lowering.  I don't see any reason offhand for the different face to
affect it, but unfortunately I really can't say for sure.

(defun tex-font-lock-suscript (pos)
  (unless (or (memq (get-text-property pos 'face)
		    '(font-lock-constant-face font-lock-builtin-face
		      font-lock-comment-face tex-verbatim))
	      ;; Check for backslash quoting
	      (let ((odd nil)
		    (pos pos))
		(while (eq (char-before pos) ?\\)
		  (setq pos (1- pos) odd (not odd)))
		odd))
    (if (eq (char-after pos) ?_)
	'(face subscript display (raise -0.3))
      '(face superscript display (raise +0.3)))))

Sorry I can't help more.

Best,
Karl




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: latex mode, nexted subscripts are unreadable
  2007-09-14  0:24   ` Karl Berry
@ 2007-09-14 16:47     ` Tim Hesterberg
  0 siblings, 0 replies; 9+ messages in thread
From: Tim Hesterberg @ 2007-09-14 16:47 UTC (permalink / raw)
  To: Karl Berry; +Cc: bug-gnu-emacs

Thanks.  I think I'm set now.

(1) I've now added this to my .emacs latex-mode-hook
	     ; Modify ratio of font sizes for suscripts; I was getting
	     ; small unreadable nested fonts with these at the default 0.8
	     (set-face-attribute 'subscript nil :height '0.82)
	     (set-face-attribute 'superscript nil :height '0.82)
That should be enough for my use; thanks for your suggestion.
.82 is enough to handle nested subscripts; .88 would handle an extra
level of nesting.  I'm using the default Courier New 10 as my normal font.

(2) I mentioned the "separate bug" about raising of nested suscripts.
I thought this only occurred after changing the height attribute;
but this occurs even without that, it just wasn't apparent to me before
(sorry).

I don't think this is that important, and my guess is that the
programming required to handle differential raising of different
levels of nested suscripts would get onerous, and might affect performance.
Hence it is probably not worth the time it would take to do.

Thank you very much.

Tim

>    I tried evaluating a modified defface definition  (in a temporary file,
>    not by changing tex-mode.el) but this had no effect.
>
>I believe that defface is like defvar et al; if the symbol is already
>defined, it won't do anything.  You can call modify-face or
>set-face-attribute from Elisp to change existing faces.
>    
>    $a_{b^c}$ makes $c$ elevated at the same level as the $c$ in $a^c$;
>    the raising is done relative to $a$ rather than to $b$.
>    Maybe this is a separate bug?
>
>Maybe.  I believe this is the code in tex-mode.el that does the raising
>and lowering.  I don't see any reason offhand for the different face to
>affect it, but unfortunately I really can't say for sure.
>
>(defun tex-font-lock-suscript (pos)
>...
>
>Best,
>Karl




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: latex mode, nexted subscripts are unreadable
  2007-09-12 22:34 ` Jason Rumney
  2007-09-13  0:48   ` Tim Hesterberg
@ 2007-09-26  7:41   ` Glenn Morris
  1 sibling, 0 replies; 9+ messages in thread
From: Glenn Morris @ 2007-09-26  7:41 UTC (permalink / raw)
  To: Jason Rumney; +Cc: bug-gnu-emacs, timh, Karl Berry

Jason Rumney wrote:

>>     the nested suscripts are visible, but are still too tiny for comfort.
>>     And they're not clearly visible - the gray letters end up with most of
>>     the pixels light gray and a few of them darker.
[...]
> It depends on the font used and the antialiasing settings of the system.
> I imagine you could reproduce it on X in the emacs-unicode-2 branch with
> the xft font backend enabled, some tinkering with /etc/fonts/fonts.conf
> (or whatever the fontconfig configuration file is on your system) and
> Courier New or a similar poorly designed truetype font.

I've been playing around with a way to set a minimum size for
suscripts. Perhaps something like this patch against the CVS trunk?
Eg try

(setq tex-suscript-height-minimum 0.9)


*** tex-mode.el	25 Sep 2007 00:29:33 -0700	1.204
--- tex-mode.el	26 Sep 2007 00:36:43 -0700	
***************
*** 676,687 ****
  	  (put-text-property beg next 'display nil))
        (setq beg next))))
  
  (defface superscript
!   '((t :height 0.8)) ;; :raise 0.2
    "Face used for superscripts."
    :group 'tex)
  (defface subscript
!   '((t :height 0.8)) ;; :raise -0.2
    "Face used for subscripts."
    :group 'tex)
  
--- 676,713 ----
  	  (put-text-property beg next 'display nil))
        (setq beg next))))
  
+ (defcustom tex-suscript-height-ratio 0.8
+   "Ratio of subscript/superscript height to that of the preceding text.
+ This is subject to the limit set by `tex-suscript-height-minimum'."
+   :type 'float
+   :group 'tex
+   :version "23.1")
+ 
+ (defcustom tex-suscript-height-minimum 0.0
+   "Integer or float limiting the minimum size of subscript/superscript text.
+ An integer is an absolute height in units of 1/10 point, a float
+ is a height relative to that of the default font.  Zero means no minimum."
+   :type '(choice (integer :tag "Integer height in 1/10 point units")
+ 		 (float :tag "Fraction of default font height"))
+   :group 'tex
+   :version "23.1")
+ 
+ (defun tex-suscript-height (height)
+   "Return the integer height of subscript/superscript font in 1/10 points.
+ Not smaller than the value set by `tex-suscript-height-minimum'."
+   (ceiling (max (if (integerp tex-suscript-height-minimum)
+ 		    tex-suscript-height-minimum
+ 		  (* tex-suscript-height-minimum
+ 		     (face-attribute 'default :height)))
+ 		;; NB assumes height is integer.
+ 		(* height tex-suscript-height-ratio))))
+ 
  (defface superscript
!   '((t :height tex-suscript-height)) ;; :raise 0.2
    "Face used for superscripts."
    :group 'tex)
  (defface subscript
!   '((t :height tex-suscript-height)) ;; :raise -0.2
    "Face used for subscripts."
    :group 'tex)
  




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-09-26  7:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-06 23:21 latex mode, nexted subscripts are unreadable Tim Hesterberg
  -- strict thread matches above, loose matches on Subject: below --
2007-09-12 18:12 Karl Berry
2007-09-12 22:34 ` Jason Rumney
2007-09-13  0:48   ` Tim Hesterberg
2007-09-13 15:03     ` Drew Adams
2007-09-26  7:41   ` Glenn Morris
2007-09-12 23:40 ` Tim Hesterberg
2007-09-14  0:24   ` Karl Berry
2007-09-14 16:47     ` Tim Hesterberg

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).