Difference between revisions of "Right and left"

From ConTeXt wiki
(Expanded, with examples and the new "flushleft" and "flushright".)
m (Changed example to include \framed.)
Line 1: Line 1:
 
< [[Bugs and workarounds]] | [[FAQ]] >
 
< [[Bugs and workarounds]] | [[FAQ]] >
  
The <tt>right</tt> and <tt>left</tt> alignments are backwards from the usual directions in all commands that accept an <tt>align=</tt> option.  For instance,  
+
The <tt>right</tt> and <tt>left</tt> alignments are backwards from the usual directions in all commands that accept an alignment option.  For instance,  
  
 
<texcode>
 
<texcode>
 
\startalignment[left]
 
\startalignment[left]
This is some aligned text, with \type{align=left}.
+
This is some aligned text, with \type{left} alignment.
 
\stopalignment
 
\stopalignment
  
\startalignment[right]
+
\framed[align=right,width=\textwidth]{Some framed text, with \type{align=right}.}
This is some aligned text, with \type{align=right}.
 
\stopalignment
 
 
</texcode>
 
</texcode>
  
Line 17: Line 15:
 
<context>
 
<context>
 
\startalignment[left]
 
\startalignment[left]
This is some aligned text, with \type{align=left}.
+
This is some aligned text, with \type{left} alignment.
 
\stopalignment
 
\stopalignment
  
\startalignment[right]
+
\framed[align=right,width=\textwidth]{Some framed text, with \type{align=right}.}
This is some aligned text, with \type{align=right}.
 
\stopalignment
 
 
</context>
 
</context>
  
Line 31: Line 27:
 
<texcode>
 
<texcode>
 
\startalignment[flushleft]
 
\startalignment[flushleft]
This is some aligned text, with \type{align=flushleft}.
+
This is some aligned text, with \type{flushleft} alignment.
 
\stopalignment
 
\stopalignment
  
\startalignment[flushright]
+
\framed[align=flushright,width=\textwidth]{Some framed text, with \type{align=flushright}.}
This is some aligned text, with \type{align=flushright}.
 
\stopalignment
 
 
</texcode>
 
</texcode>
  
Line 43: Line 37:
 
<context>
 
<context>
 
\startalignment[flushleft]
 
\startalignment[flushleft]
This is some aligned text, with \type{align=flushleft}.
+
This is some aligned text, with \type{flushleft} alignment.
 
\stopalignment
 
\stopalignment
  
\startalignment[flushright]
+
\framed[align=flushright,width=\textwidth]{Some framed text, with \type{align=flushright}.}
This is some aligned text, with \type{align=flushright}.
 
\stopalignment
 
 
</context>
 
</context>
  
Incidentally, note that <cmd>leftaligned</cmd> and <cmd>rightaligned</cmd> also produce flush-left and flush-right alignment, with
+
Incidentally, note that <cmd>leftaligned</cmd> and <cmd>rightaligned</cmd> produce flush-left and flush-right alignment, with
  
 
<texcode>
 
<texcode>

Revision as of 02:15, 6 September 2005

< Bugs and workarounds | FAQ >

The right and left alignments are backwards from the usual directions in all commands that accept an alignment option. For instance,

\startalignment[left]
This is some aligned text, with \type{left} alignment.
\stopalignment

\framed[align=right,width=\textwidth]{Some framed text, with \type{align=right}.}

produces

Unfortunately, when Hans was first writing this part of ConTeXt, he was thinking of "ragged right" and "ragged left" alignment, rather than "flush left" and "flush right". And now that it's been this way a while, it's impossible to change it, because changing it would break backward compatibility with all of the existing documents that use it.

If you'd rather not try to remember that it's backwards, ConTeXt now supports flushleft and flushright options, which do exactly the same thing, but in the "correct" direction. Thus:

\startalignment[flushleft]
This is some aligned text, with \type{flushleft} alignment.
\stopalignment

\framed[align=flushright,width=\textwidth]{Some framed text, with \type{align=flushright}.}

produces

Incidentally, note that \leftaligned and \rightaligned produce flush-left and flush-right alignment, with

\leftaligned{This is some \type{leftaligned} text.}
\rightaligned{This is some \type{rightaligned} text.}

producing