File indexing completed on 2024-11-24 04:34:44
0001 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 0002 <html> 0003 <!-- This document is an unofficial reference manual for LaTeX, a 0004 document preparation system, version of November 2018. 0005 0006 This manual was originally translated from LATEX.HLP v1.0a in the 0007 VMS Help Library. The pre-translation version was written by 0008 George D. Greenwade of Sam Houston State University. The 0009 LaTeX 2.09 version was written by Stephen Gilmore. The 0010 LaTeX2e version was adapted from this by Torsten Martinsen. Karl 0011 Berry made further updates and additions, and gratefully acknowledges 0012 using Hypertext Help with LaTeX, by Sheldon Green, and 0013 LaTeX Command Summary (for LaTeX 2.09) by 0014 L. Botway and C. Biemesderfer (published by the TeX Users 0015 Group as TeXniques number 10), as reference material. We also 0016 gratefully acknowledge additional material appearing in 0017 latex2e-reference by Martin Herbert Dietze. (From these references no 0018 text was directly copied.) 0019 0020 Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013, 0021 2014, 2015, 2016, 2017, 2018 Karl Berry. 0022 0023 Copyright 1988, 1994, 2007 Stephen Gilmore. 0024 0025 Copyright 1994, 1995, 1996 Torsten Martinsen. 0026 0027 Permission is granted to make and distribute verbatim copies of 0028 this manual provided the copyright notice and this permission notice 0029 are preserved on all copies. 0030 0031 0032 Permission is granted to copy and distribute modified versions of this 0033 manual under the conditions for verbatim copying, provided that the entire 0034 resulting derived work is distributed under the terms of a permission 0035 notice identical to this one. 0036 0037 Permission is granted to copy and distribute translations of this manual 0038 into another language, under the above conditions for modified versions. --> 0039 <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ --> 0040 <head> 0041 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 0042 <title>Lengths (LaTeX2e unofficial reference manual (November 2018))</title> 0043 0044 <meta name="description" content="Lengths (LaTeX2e unofficial reference manual (November 2018))"> 0045 <meta name="keywords" content="Lengths (LaTeX2e unofficial reference manual (November 2018))"> 0046 <meta name="resource-type" content="document"> 0047 <meta name="distribution" content="global"> 0048 <meta name="Generator" content="makeinfo"> 0049 <link href="index.html#Top" rel="start" title="Top"> 0050 <link href="IndexDocument.html#Index" rel="index" title="Index"> 0051 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 0052 <link href="index.html#Top" rel="up" title="Top"> 0053 <link href="Units-of-length.html#Units-of-length" rel="next" title="Units of length"> 0054 <link href="_005cday-_0026-_005cmonth-_0026-_005cyear.html#g_t_005cday-_0026-_005cmonth-_0026-_005cyear" rel="prev" title="\day & \month & \year"> 0055 <style type="text/css"> 0056 <!-- 0057 /* $Id: latex2e.css 690 2018-09-15 15:20:19Z jimhefferon $ 0058 Minor css for latexrefman. Public domain. 0059 Originally written by Jim Hefferon and Karl Berry, 2018. */ 0060 0061 /* So you can style for yourself */ 0062 @import url("/css/latexreflocal.css"); 0063 0064 0065 0066 a.summary-letter {text-decoration: none} 0067 blockquote.indentedblock {margin-right: 0em} 0068 blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} 0069 blockquote.smallquotation {font-size: smaller} 0070 div.display {margin-left: 3.2em} 0071 div.example {margin-left: 3.2em} 0072 div.lisp {margin-left: 3.2em} 0073 div.smalldisplay {margin-left: 3.2em} 0074 div.smallexample {margin-left: 3.2em} 0075 div.smalllisp {margin-left: 3.2em} 0076 kbd {font-style: oblique} 0077 pre.display {font-family: inherit} 0078 pre.format {font-family: inherit} 0079 pre.menu-comment {font-family: serif} 0080 pre.menu-preformatted {font-family: serif} 0081 pre.smalldisplay {font-family: inherit; font-size: smaller} 0082 pre.smallexample {font-size: smaller} 0083 pre.smallformat {font-family: inherit; font-size: smaller} 0084 pre.smalllisp {font-size: smaller} 0085 span.nolinebreak {white-space: nowrap} 0086 span.roman {font-family: initial; font-weight: normal} 0087 span.sansserif {font-family: sans-serif; font-weight: normal} 0088 ul.no-bullet {list-style: none} 0089 BODY { 0090 margin-top: 1em; 0091 margin-left: 1em; /* auto results in two-digit <ol> lost off left */ 0092 margin-right: 1em; 0093 margin-bottom: 1em; 0094 /* the idea is to use the whole window, unless it is ridiculously 0095 wide, probably with too-small fonts, too. */ 0096 max-width: 64em; 0097 } 0098 0099 /* Because we want @math{... @code ...} to be upright, not slanted, 0100 and Texinfo won't fix it. */ 0101 code {font-style:normal; font-family:monospace; } 0102 0103 /* We put a link to our own home page at the bottom. */ 0104 div.referenceinfo {font-size:small;} 0105 0106 --> 0107 </style> 0108 0109 0110 </head> 0111 0112 <body lang="en"> 0113 <a name="Lengths"></a> 0114 <div class="header"> 0115 <p> 0116 Next: <a href="Making-paragraphs.html#Making-paragraphs" accesskey="n" rel="next">Making paragraphs</a>, Previous: <a href="Counters.html#Counters" accesskey="p" rel="prev">Counters</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="IndexDocument.html#Index" title="Index" rel="index">Index</a>]</p> 0117 </div> 0118 <hr> 0119 <a name="Lengths-1"></a> 0120 <h2 class="chapter">14 Lengths</h2> 0121 0122 <a name="index-lengths_002c-defining-and-using"></a> 0123 0124 <p>A <em>length</em> is a measure of distance. Many LaTeX commands take a 0125 length as an argument. 0126 </p> 0127 <p>Lengths come in two types. A <em>rigid length</em> such as <code>10pt</code> 0128 does not contain a <code>plus</code> or <code>minus</code> component. (Plain TeX 0129 calls this a <em>dimen</em>.) A <em>rubber length</em> (what Plain TeX 0130 calls a <em>skip</em>) such as as with <code>1cm plus0.05cm minus0.01cm</code> 0131 can contain either or both of those components. In that rubber length, 0132 the <code>1cm</code> is the <em>natural length</em> while the other two, the 0133 <code>plus</code> and <code>minus</code> components, allow TeX to stretch or 0134 shrink the length to optimize placement. 0135 </p> 0136 <p>The illustrations below use these two commands. 0137 </p> 0138 <div class="example"> 0139 <pre class="example">% make a black bar 10pt tall and #1 wide 0140 \newcommand{\blackbar}[1]{\rule{#1}{10pt}} 0141 0142 % Make a box around #2 that is #1 wide (excluding the border) 0143 \newcommand{\showhbox}[2]{% 0144 \fboxsep=0pt\fbox{\hbox to #1{#2}}} 0145 </pre></div> 0146 0147 <p>This example uses those commands to show a black bar 100 points 0148 long between ‘<samp>XXX</samp>’ and ‘<samp>YYY</samp>’. This length is rigid. 0149 </p> 0150 <div class="example"> 0151 <pre class="example">XXX\showhbox{100pt}{\blackbar{100pt}}YYY 0152 </pre></div> 0153 0154 <p>As for rubber lengths, shrinking is simpler one: with <code>1cm minus 0155 0.05cm</code>, the natural length is 1cm but TeX can shrink it down 0156 as far as 0.95cm. Beyond that, TeX refuses to shrink any more. 0157 Thus, below the first one works fine, producing a space of 0158 98 points between the two bars. 0159 </p> 0160 <div class="example"> 0161 <pre class="example">XXX\showhbox{300pt}{% 0162 \blackbar{101pt}\hspace{100pt minus 2pt}\blackbar{101pt}}YYY 0163 0164 XXX\showhbox{300pt}{% 0165 \blackbar{105pt}\hspace{100pt minus 1pt}\blackbar{105pt}}YYY 0166 </pre></div> 0167 0168 <p>But the second one gets a warning like ‘<samp>Overfull \hbox (1.0pt too 0169 wide) detected at line 17</samp>’. In the output the first ‘<samp>Y</samp>’ is 0170 overwritten by the end of the black bar, because the box’s material is 0171 wider than the 300pt allocated, as TeX has refused to shrink 0172 the total to less than 309 points. 0173 </p> 0174 <p>Stretching is like shrinking except that if TeX is asked to stretch 0175 beyond the given amount, it will do it. Here the first line is fine, 0176 producing a space of 110 points between the bars. 0177 </p> 0178 <div class="example"> 0179 <pre class="example">XXX\showhbox{300pt}{% 0180 \blackbar{95pt}\hspace{100pt plus 10pt}\blackbar{95pt}}YYY 0181 0182 XXX\showhbox{300pt}{% 0183 \blackbar{95pt}\hspace{100pt plus 1pt}\blackbar{95pt}}YYY 0184 </pre></div> 0185 0186 <p>In the second line TeX needs a stretch of 10 points and only 0187 1 point was specified. TeX stretches the space to the required 0188 length but it gives you a warning like ‘<samp>Underfull \hbox (badness 0189 10000) detected at line 22</samp>’. (We won’t discuss badness.) 0190 </p> 0191 <p>You can put both stretch and shrink in the same length, as in 0192 <code>1ex plus 0.05ex minus 0.02ex</code>. 0193 </p> 0194 <p>If TeX is setting two or more rubber lengths then it allocates the 0195 stretch or shrink in proportion. 0196 </p> 0197 <div class="example"> 0198 <pre class="example">XXX\showhbox{300pt}{% 0199 \blackbar{100pt}% left 0200 \hspace{0pt plus 50pt}\blackbar{80pt}\hspace{0pt plus 10pt}% middle 0201 \blackbar{100pt}}YYY % right 0202 </pre></div> 0203 0204 <p>The left and right bars take up 100 points, so the middle needs 0205 another 100. The middle bar is 80 points so the two 0206 <code>\hspace</code>’s must stretch 20 points. Because the two are 0207 <code>plus 50pt</code> and <code>plus 10pt</code>, TeX gets 5/6 of the stretch 0208 from the first space and 1/6 from the second. 0209 </p> 0210 <p>The <code>plus</code> or <code>minus</code> component of a rubber length can contain 0211 a <em>fill</em> component, as in <code>1in plus2fill</code>. This gives the 0212 length infinite stretchability or shrinkability so that TeX could set 0213 it to any distance. Here the two figures will be equal-spaced across 0214 the page. 0215 </p> 0216 <div class="example"> 0217 <pre class="example">\begin{minipage}{\linewidth} 0218 \hspace{0pt plus 1fill}\includegraphics{godel.png}% 0219 \hspace{0pt plus 1fill}\includegraphics{einstein.png}% 0220 \hspace{0pt plus 1fill} 0221 \end{minipage} 0222 </pre></div> 0223 0224 <p>TeX actually has three levels of infinity for glue components: 0225 <code>fil</code>, <code>fill</code>, and <code>filll</code>. The later ones are more 0226 infinite than the earlier ones. Ordinarily document authors only use 0227 the middle one (see <a href="_005chfill.html#g_t_005chfill">\hfill</a> and see <a href="_005cvfill.html#g_t_005cvfill">\vfill</a>). 0228 </p> 0229 <p>Multiplying a rubber length by a number turns it into a rigid length, so 0230 that after <code>\setlength{\ylength}{1in plus 0.2in}</code> and 0231 <code>\setlength{\zlength}{3\ylength}</code> then the value of 0232 <code>\zlength</code> is <code>3in</code>. 0233 </p> 0234 <table class="menu" border="0" cellspacing="0"> 0235 <tr><td align="left" valign="top">• <a href="Units-of-length.html#Units-of-length" accesskey="1">Units of length</a>:</td><td> </td><td align="left" valign="top">The units that LaTeX knows. 0236 </td></tr> 0237 <tr><td align="left" valign="top">• <a href="_005csetlength.html#g_t_005csetlength" accesskey="2">\setlength</a>:</td><td> </td><td align="left" valign="top">Set the value of a length. 0238 </td></tr> 0239 <tr><td align="left" valign="top">• <a href="_005caddtolength.html#g_t_005caddtolength" accesskey="3">\addtolength</a>:</td><td> </td><td align="left" valign="top">Add a quantity to a length. 0240 </td></tr> 0241 <tr><td align="left" valign="top">• <a href="_005csettodepth.html#g_t_005csettodepth" accesskey="4">\settodepth</a>:</td><td> </td><td align="left" valign="top">Set a length to the depth of something. 0242 </td></tr> 0243 <tr><td align="left" valign="top">• <a href="_005csettoheight.html#g_t_005csettoheight" accesskey="5">\settoheight</a>:</td><td> </td><td align="left" valign="top">Set a length to the height of something. 0244 </td></tr> 0245 <tr><td align="left" valign="top">• <a href="_005csettowidth.html#g_t_005csettowidth" accesskey="6">\settowidth</a>:</td><td> </td><td align="left" valign="top">Set a length to the width of something. 0246 </td></tr> 0247 </table> 0248 0249 0250 0251 0252 <hr/><div class='referenceinfo'> <a href='https://latexref.xyz/'> <i>Unofficial LaTeX2e reference manual</i></a></div> 0253 </body> 0254 </html>