Difference between revisions of "KOMA-scrartcl Type Area"

From Wiki
Jump to navigation Jump to search
 
(Added some explanation of what the code appears to be attempting to do.)
Line 2: Line 2:
  
 
LaTeX:
 
LaTeX:
 +
 +
The <tt>scrartcl</tt> class from the KOMA package does some fairly sophisticated calculations to determine an appropriate page layout.  A sample document (with a framebox to show the text area) is simply:
 
<pre>
 
<pre>
 
\documentclass[DIVcalc,twoside]{scrartcl}
 
\documentclass[DIVcalc,twoside]{scrartcl}
Line 10: Line 12:
  
 
ConTeXt:
 
ConTeXt:
 +
 +
The following code duplicates the <tt>scrartcl</tt> calculations to set the text area and produces a similar sample document, again with a framed box to show the text area.
 
<pre>
 
<pre>
 
\def\BCOR{3mm}% eventual bounding correction
 
\def\BCOR{3mm}% eventual bounding correction

Revision as of 05:38, 8 August 2004

< From LaTeX to ConTeXt

LaTeX:

The scrartcl class from the KOMA package does some fairly sophisticated calculations to determine an appropriate page layout. A sample document (with a framebox to show the text area) is simply:

\documentclass[DIVcalc,twoside]{scrartcl}
\begin{document}
\noindent\framebox{\rule{0pt}{\textheight}\rule{\textwidth}{0pt}}
\end{document}

ConTeXt:

The following code duplicates the scrartcl calculations to set the text area and produces a similar sample document, again with a framed box to show the text area.

\def\BCOR{3mm}% eventual bounding correction
\newdimen\PageWidth \PageWidth=\paperwidth
\doifmode{BCOR}{\PageWidth=\dimexpr(\PageWidth-\BCOR)}
\edef\Ratio{\withoutpt{\the\dimexpr(2\paperheight/(\PageWidth/32768))}}
\setbox\scratchbox\hbox{\dorecurse{26}{\character\recurselevel}}
\newdimen\Width \newdimen\Height \newdimen\Back
\Width=\dimexpr(2.6\wd\scratchbox) \Height=\dimexpr(\Ratio\Width)
\doifmodeelse{oneside}{\Back=\dimexpr((\PageWidth - \Width) / 2)}
    {\Back=\dimexpr((\PageWidth - \Width) / 3)}
\doifmode{BCOR}{\Back=\dimexpr(\Back + \BCOR)}
\edef\Top{\the\dimexpr((\paperheight - \Height) / 3 - 3\lineheight)}
\Height=\dimexpr(\Height + 8\lineheight)
\setuplayout[backspace=\the\Back,height=\the\Height,width=\the\Width,
header=2\lineheight,headerdistance=\lineheight,
footer=2\lineheight,footerdistance=3\lineheight,topspace=\Top]

\starttext
\framed[width=\textwidth,height=\textheight]{}
\stoptext

In the beta version of ConTeXt, there is probably a better way to achieve the same...