Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the memoir manual speaks about

measuring the length of the lowercase alphabet

in order to decide the numbers of characters per line. Can this be done with LaTeX?

share|improve this question
    
Both answers seem to be equal correct and elegant (at least to my eyes). I can't decide which one I should accept... –  pmav99 May 4 '11 at 19:21
    
My answer is the "official" LaTeX way, while Yiannis one uses plainTeX macros. I personally actually use that macros more often because you only need to box the content once and get the height, width and depth using \ht, \wd and \dp respectively. –  Martin Scharrer May 4 '11 at 20:07
add comment

3 Answers 3

up vote 17 down vote accepted

If with the length it means the width of all lowercase letters than you can use \settowidth{<length register>}{<content>}:

\documentclass{article}
\begin{document}
  \newlength{\alphabetlength}
  \settowidth{\alphabetlength}{abcdefghijklmnopqrstuvwxyz}
  \the\alphabetlength
\end{document}

(I took the liberty to use the same format as Yiannis answer to allow for better comparison. His answer is fine too, but I wanted to show the official LaTeX way.)

share|improve this answer
    
Thank you! –  pmav99 May 4 '11 at 19:22
add comment

You can place the letters in a box and measure its length. Here is a minimal to do this.

\documentclass{article}
\begin{document}
  \newbox\alphabet
  \sbox\alphabet{abcdefghijklmnopqrstuvwxyz}
  \the\wd\alphabet
\end{document}
share|improve this answer
    
@Yiannis Ευχαριστώ - Thank you! –  pmav99 May 4 '11 at 19:23
    
@pmav99 \textgreek{parakal`w} –  Yiannis Lazarides May 4 '11 at 19:32
    
@Yiannis You are hardcore! This is the Unicode age :P –  pmav99 May 4 '11 at 19:47
    
I finally chose Martin's answer as he uses one less `\` ... LOL –  pmav99 May 4 '11 at 19:49
2  
@pmav99 I see, my solution was optimized for the minimum number of curly brackets! –  Yiannis Lazarides May 5 '11 at 3:33
show 1 more comment

Just for the record, page 15 of memman.pdf brings the following to print the length of the lowercase alphabet:

\newlength{\mylen}                % a length
\newcommand{\alphabet}{abc...xyz} % the lowercase alphabet
\begingroup                       % keep font change local
% font specification e.g., \Large\sffamily
\settowidth{\mylen}{\alphabet}
The length of this alphabet is \the\mylen. % print in document
\typeout{The length of the Large sans alphabet
    is \the\mylen}                         % put in log file
\endgroup                         % end the grouping

Which is basically @Martin's way.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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