Math & ScienceWeird spacing problem

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Weird spacing problem

Post by Montag »

Hello,

I don't know what to do here: The underlined sigma should not look fine (see my screenshot with URW's GaramondNo8), but indeed does look ok with the Latin Modern, and I've just noticed the not existing horizontal space between the \dund{D} and \uli{u}.
Could anyone give me a hint what the problem is, or if I misunderstood something?
Latin Modern:
screenshot.JPG
screenshot.JPG (16.62 KiB) Viewed 5950 times
GaramondNo8 with mathdesign:
screenshot-garamond.JPG
screenshot-garamond.JPG (31.93 KiB) Viewed 5949 times
Attachments
weird-spacing.tex
(389 Bytes) Downloaded 184 times
Last edited by Montag on Thu Jan 20, 2011 9:43 am, edited 1 time in total.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: Weird spacing problem

Post by frabjous »

Out of curiousity, can you still tell the difference printed?
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Weird spacing problem

Post by Montag »

frabjous wrote:Out of curiousity, can you still tell the difference printed?
Yes, I can, it looks weird. What's the way to go, is it common to add horizontal space via \, or something alike? :)

The underline sigma set in GaramondNo8 looks simply horrible. :/
But using the Minion Pro font which is provided via CTAN, it looks ok. I guess I'll stick to any font except the GaramondNo8 then.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Weird spacing problem

Post by frabjous »

Yeah, it does seem to be a problem with that font: it doesn't seem to know how tall its own characters are. That's especially true of \sigma apparently. You could use commands like \smash to force them into submission. With the Du and D\epsilon constructions, I think the only thing you could try to do would be to try to force the underlining that goes under both to come from the same \underline command, and then get the second underline under the D by putting in a zero-width double-underlined phantom D before it, e.g.:

Code: Select all

\documentclass{scrartcl}
\usepackage[english]{babel}
\usepackage[garamond]{mathdesign}
\usepackage{amsmath}

\newcommand{\uli}[1]{\underline{#1}}
\newcommand{\dund}[1]{\underline{\underline{#1}}}

\begin{document}
\begin{align*}
\uli{\varepsilon} &= \rlap{\uli{\phantom{\uli{D}}}}\uli{Du} \\
\uli{\smash\sigma} &= \rlap{\uli{\phantom{\uli{D}}}}\uli{D\varepsilon}
\end{align*}
\end{document}
smash.png
smash.png (2.12 KiB) Viewed 5937 times
But that's a lot of work if you have a lot of these constructions popping up, and kind of an ugly kludge. If this is just a couple equations here and there, it might be worth it if you really had your heart set on Garamond/mathdesign.

Surely Minion Pro isn't provided by CTAN? Adobe owns that font. Do you mean the package that is on CTAN for use with the Adobe fonts?
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Weird spacing problem

Post by Montag »

frabjous wrote:But that's a lot of work if you have a lot of these constructions popping up, and kind of an ugly kludge. If this is just a couple equations here and there, it might be worth it if you really had your heart set on Garamond/mathdesign.
Hm, yes, you are right, it is a lot of work. And these constructions appear a lot, so not using Garamond isn't that bad here. Thank you for your code though!
Surely Minion Pro isn't provided by CTAN? Adobe owns that font. Do you mean the package that is on CTAN for use with the Adobe fonts?
Oh, yes, I know, I meant this version which I use.

But could you add anything to my other question about the horizontal space, if possible?
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: Weird spacing problem

Post by frabjous »

I guess I don't understand the horizontal space question. Why should/would there be horizontal space there? In math mode, spaces in the code never do anything. The spacing is controlled by the semantic/syntactic nature of the symbols. If you wanted space, you'd have to put it in, or change the syntactic category of the symbols (with e.g., \mathalpha, \mathord, \mathop, \mathrel, \mathpunct, \mathleft, \mathright, etc.)
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Weird spacing problem

Post by Montag »

frabjous wrote:I guess I don't understand the horizontal space question. Why should/would there be horizontal space there? In math mode, spaces in the code never do anything. The spacing is controlled by the semantic/syntactic nature of the symbols. If you wanted space, you'd have to put it in, or change the syntactic category of the symbols (with e.g., \mathalpha, \mathord, \mathop, \mathrel, \mathpunct, \mathleft, \mathright, etc.)
Hm, yes, that makes sense. :) But I asked because after I discovered -- and actually remembered -- that I had a lot of scripts of lectures at my university in my hands, where it looked like the math (I specifically mean the matrices and vectors) was set with what looks like a \,. So I thought I'd ask, maybe there's an easy to save me the trouble of setting the space all the time for these constructions. But then, maybe not setting space is the norm.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Weird spacing problem

Post by Montag »

And when compiling this
kpfonts-overline-problem.tex
(273 Bytes) Downloaded 251 times
I get this:
kpfonts-thing.JPG
kpfonts-thing.JPG (11.63 KiB) Viewed 5914 times
Man, this is annoying, because I have to use "8pt" as a global option. :(
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Weird spacing problem

Post by frabjous »

This has nothing to do with the 8pt option. It's because of the \smash in the \und definition. My fault from some other thread, probably -- I probably shouldn't have recommended smash without telling you what it did. It basically makes LaTeX ignore what's inside the \smash{...} command when computing the vertical dimensions of something. This can be useful if you want to keep things level across different characters, etc., but can also create problems like this. As far as LaTeX knows, that K doesn't have any height, so it's overlining it too low.

You can make up its height by reinserting a \vphantom{K} which inserts the height of something without inserting that something; and then of course you'll need to smash that back down unless you want the superscript raised too. It's all very exhausting. Probably there's a better way, but I've never seen a document that uses so much overlining and underlining as the one you're apparently using.

Code: Select all

\documentclass[
8pt
]{scrartcl}

\usepackage[
notextcomp,
oldstylenums
]{kpfonts}

\newcommand{\dund}[1]{{\smash{\underline{\underline{#1}}}}}

\begin{document}
\begin{equation*}
	\dund{T}^{T} \smash{\overline{\vphantom{K}\dund{K}}}^{(e)} \dund{T}
\end{equation*}
\end{document}
tkt.png
tkt.png (1.52 KiB) Viewed 5912 times
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Weird spacing problem

Post by Montag »

frabjous wrote:This has nothing to do with the 8pt option. It's because of the \smash in the \und definition. My fault from some other thread, probably -- I probably shouldn't have recommended smash without telling you what it did. It basically makes LaTeX ignore what's inside the \smash{...} command when computing the vertical dimensions of something. This can be useful if you want to keep things level across different characters, etc., but can also create problems like this. As far as LaTeX knows, that K doesn't have any height, so it's overlining it too low.
Thank you this explanation, I appreciate it. But it's not your "fault", I looked for \smash online myself after reading this and it's actually explaiend in the Amsmath-manual -- which I should have read when you talked about \smash earlier. Thanks again.
You can make up its height by reinserting a \vphantom{K} which inserts the height of something without inserting that something; and then

[...]
tkt.png
Well, yes, it's abit exhausting, but it's necessary, but at long sight, I think I'll redefine my underlining commands either to the ones provided bei ulem or delete the \smash.
Well, it is a summary of a lecture notes which contains a lot of vectors/matrices and which I'll print out (like this). The notation of the vectors/matrices is the version with the underlinings, which I like more than the version with symbols formatted in bold.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
Post Reply