Difference between revisions of "Command/textwidth"

From Wiki
Jump to navigation Jump to search
m (Created page with "== Description == The {{cmd|textwidth}} command contains a value that represents the width of the current line on the page. The value is contextual in that if the current line i...")
 
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
== Description ==
 
== Description ==
  
The {{cmd|textwidth}} command contains a value that represents the width of the current line on the page. The value is contextual in that if the current line is within a columnar environment, then {{cmd|textwidth}} returns the value of the current column width.
+
The {{cmd|textwidth}} command contains a value that represents the width of the current line on the page. The value is contextual in that if the current line is within a columnar environment, then {{cmd|textwidth}} returns the value of the current column width. (If this does not work out for you, try {{cmd|hsize}} instead.)
  
 
== Example ==
 
== Example ==
Line 7: Line 7:
 
The following example scales a long line of text to prevent it from breaking over multiple lines.
 
The following example scales a long line of text to prevent it from breaking over multiple lines.
  
<context src=yes>
+
<context source=yes>
 
\starttext
 
\starttext
 +
  \blackrule[height=1pt,width=\makeupwidth,]
 
   \startcolumns[rule=on,]
 
   \startcolumns[rule=on,]
 
     \scale[maxwidth=\textwidth]{
 
     \scale[maxwidth=\textwidth]{
 
       This line uses the scaled command to fit within a column's width.
 
       This line uses the scaled command to fit within a column's width.
 
     }
 
     }
 +
    \column
 +
    This line avoids the scaled command and will be split using line breaks.
 
   \stopcolumns
 
   \stopcolumns
 +
  \blackrule[height=1pt,width=\makeupwidth,]
 
\stoptext
 
\stoptext
 
</context>
 
</context>

Latest revision as of 20:57, 31 August 2014

Description

The \textwidth command contains a value that represents the width of the current line on the page. The value is contextual in that if the current line is within a columnar environment, then \textwidth returns the value of the current column width. (If this does not work out for you, try \hsize instead.)

Example

The following example scales a long line of text to prevent it from breaking over multiple lines.

\starttext
  \blackrule[height=1pt,width=\makeupwidth,]
  \startcolumns[rule=on,]
    \scale[maxwidth=\textwidth]{
      This line uses the scaled command to fit within a column's width.
    }
    \column
    This line avoids the scaled command and will be split using line breaks.
  \stopcolumns
  \blackrule[height=1pt,width=\makeupwidth,]
\stoptext

See Also