Difference between revisions of "From LaTeX to ConTeXt"

From Wiki
Jump to navigation Jump to search
m (Move link to Vietnamese version to top of page.)
(One intermediate revision by the same user not shown)
Line 91: Line 91:
  
 
* [[LaTeX Math in ConTeXt]]
 
* [[LaTeX Math in ConTeXt]]
 
  
 
=== Copy-Paste text between LaTeX and ConTeXt ===
 
=== Copy-Paste text between LaTeX and ConTeXt ===
Line 98: Line 97:
  
 
''<code>\section</code> works the same way as in LaTeX, for mathematics take a look into [[LaTeX Math in ConTeXt]], use <code>\bf</code> instead of <code>\textbf</code> for both LaTeX and ConTeXt (or <code><nowiki>\def\textbf#1{{\bf #1}}</nowiki></code>) and as a general rule: use as many plain TeX macros as possible instead of LaTeX-specific macros. <code>\begin ... \end</code> only works for math as far as I know. See also other documents listed above  or ask on the mailing list.''
 
''<code>\section</code> works the same way as in LaTeX, for mathematics take a look into [[LaTeX Math in ConTeXt]], use <code>\bf</code> instead of <code>\textbf</code> for both LaTeX and ConTeXt (or <code><nowiki>\def\textbf#1{{\bf #1}}</nowiki></code>) and as a general rule: use as many plain TeX macros as possible instead of LaTeX-specific macros. <code>\begin ... \end</code> only works for math as far as I know. See also other documents listed above  or ask on the mailing list.''
 
 
<!--
 
<!--
 
* [[LaTeX&ConTeXt/Introduction|Introduction]]
 
* [[LaTeX&ConTeXt/Introduction|Introduction]]

Revision as of 22:17, 14 May 2012

< Main Page >

General hints for converting from LaTeX to Context can be found in

A Vietnamese version is available at VnOSS.

This page offers specific advice on a number of special things that you may be doing with LaTeX, but are not so obvious to do with ConTeXt.

Document and Page Layout

Text Formatting

Idiomatic Differences Between ConTeXt and LaTeX

Brackets and Braces

{..} [..]
LaTeX command arguments optional arguments
ConTeXt typeset material; scope or range of the command (the text acted upon) is placed between curly brackets setups instructions and metadata (options)

Optional Arguments and Setups

In ConTeXt, arguments may be either comma separated lists or assignments, but not both. The following example demonstrates that LaTeX allows either syntax in optional arguments:

 \documentclass[BCOR=12mm,DIV=calc,twoside]{scrartcl}

(From the KOMA-Script manual.) ConTeXt, however, distinguishes strictly between both types for processing them internally relies on two different mechanisms. Therefore, setups like \itemize usually allow two sets of optional arguments [1], the comma list preceding the assignment:

\starttext

\startitemize [R,2*broad][
  start=11,
  before=\startlinecorrection,
  after=\stoplinecorrection,
]
  \item Foo,
  \item bar,
  \item baz.
\stopitemize

\stoptext

The ConTeXt interface definitions (collected by Wolfgang in the macro reference) use a special notation to indicate whether an argument expects assignment or list syntax:

\defineframedtext [...] [...] [..,.=.,..]

where [...] stands for the list type and [..,.=.,..] denotates an assignment.

Programming

Document Metadata

Math

Copy-Paste text between LaTeX and ConTeXt

It is sometimes useful to have the same source for a LaTeX document and a ConTeXt presentation (or a ConTeXt document and a LaTeX presentation). However, the commands used by both are very different. Can someone describe some definitions in ConTeXt that implement the core functionality of LaTeX commands like \section et al, \textbf et al, \bfseries et al and \begin \end pairs?

\section works the same way as in LaTeX, for mathematics take a look into LaTeX Math in ConTeXt, use \bf instead of \textbf for both LaTeX and ConTeXt (or \def\textbf#1{{\bf #1}}) and as a general rule: use as many plain TeX macros as possible instead of LaTeX-specific macros. \begin ... \end only works for math as far as I know. See also other documents listed above or ask on the mailing list.

Functionality of Latex Packages in Context