tags:

views:

279

answers:

3

In this sample code, the author does the following

\draw ($(closedStart.south) + (-.5em,0)$) 
      edge[stateEdge] node[edgeLabel, xshift=-3em]{\emph{Passive open}} 
      ($(listen.north) + (-.5em,0)$);

What irritates me most about these markup based drawing tools is that I've to measure a value and specify. In this case, the author specifies .5em

I've yet not understood how to figure that out? How much is .5em? I don't even know the size of the base object, so how can I be sure that if I give a value it will be valid?

Is there any approach to do this? How should I decide the value and also the unit? Is em always the best unit to use?

+2  A: 

Google is your friend: http://en.wikipedia.org/wiki/Em%5F%28typography%29

An em is a unit of measurement in the field of typography, equal to the point size of the current font. This unit is not defined in terms of any specific typeface, and thus is the same for all fonts at a given point size. So, 1 em in a 16 point typeface is 16 points.

You can change the unit of measurement to anything supported by latex, i'm sure: in, mm, cm, pts, picas, etc etc.

Mica
That makes sense. But how will I know if .5em is sufficient or if I need 1em or 2em or .25em ... Is Trial and Error the only way out of this? Or is there a systematic and easy way to estimate these values?
ajay
Trial and error basically-- but switch to a unit of measurement you are comfortable working with. you can replace `em` with `in` or `cm` or what have you. If you work with type enough, you'll learn to gauge how large an em unit is.
Mica
You write, of ems, "This unit is not defined in terms of any specific typeface" - and though you later say "1 em in a 16 point typeface is 16 points", I think it's worth making clear that em is a measure of the scale of a font, which simply is how many points wide a capital "M" is in that font.
Charles Stewart
@Charles: the `em = M` idea makes EMs easy to understand, but isn't really that proper. In very general terms, em = M, but with digital fonts, the M does not necessarily take up the full width of the type block. Even easier, maybe, is em = em-dash. An em-dash should occupy the full width of the type block. :P
Mica
@Mica: I didn't see this comment back then. You are quite right: fonts can, and modern fonts usually do, specify their em-scale to be different than the width of their M, and indeed need not have either an M or an em dash character. I still think it is best to introduce the concept in terms of M: it is historically accurate, memorable, and the true definition involves an abstraction. I've revised my answer: I'd be grateful if you could tell me of any other errors you notice in what I say!
Charles Stewart
+1  A: 

To expand on what Mica says:

ems are the usual way that intercharacter space is measured, and is historically was the width of a character "M" in a given font ("M" normally being the widest letter in Latin-based fonts): crucially, it is a relative measure, and subscript fonts, say, have a smaller em than normal text. Modern fonts generally have narrower "M" characters than historically, and there are many non-Latin fonts, so the em measure is now derived from the dimensions of the square (or oblong) that the font designer places the character in, and is communicated as a parameter, together with such facts as the height of the baseline that text sits on, that tells us the scale of the font.

The point size of a font is the number of points (usually 1/72 inch) to an em, so a 12 point font is one whose character "M" is 1/6th of an inch wide (i.e., 12/72 in). The subscripts of a 12 point font are usually shown in a 7 point font, for which the em is just under 1/10th inch.

If you want to do positioning on a page, use points. If you want to control spacing in text, use ems because they scale.

Postscript

Fixed the discussion of the character `M', thanks to Mica.

Charles Stewart
wow, that was great!! I had no idea about any of that. Thank you :)
Vivi
@Vivi: Thanks, there were some errors in what I wrote: now revised.
Charles Stewart
+1  A: 

Hi

Not too sure how TikZ handles it but in LaTeX you can specify measurements as fractions (larger or smaller than 1) of known lengths, so you could set a length to be, say, 0.5\textwidth. My bet is that TikZ has this sort of facility so if you are going to be a long term user you'll want to figure it out.

Regards

Mark

High Performance Mark