Difference between revisions of "Running ConTeXt"

From Wiki
Jump to navigation Jump to search
m (Thangalin moved page Run scripts to Running ConTeXt: Scripts are a good idea, but maybe outside purview of wiki (due to maintenance))
Line 1: Line 1:
While ConTeXt (i.e. mtxrun) already automates a lot, in bigger projects I find it tedious to call context with all its options all the time. One might use [https://www.gnu.org/software/make/ make] or [https://github.com/cereda/arara arara], but I mostly use shell scripts (on OSX and Linux). Here are some useful snippets:
+
The [[First Document]] page provides a cursory introduction to typesetting document using ConTeXt. The [[Context]] page describes the command-line options in brief. This page provides additional information for command-line options.
  
<pre>
+
== --run ==
#!/bin/bash
 
  
OS=`uname`
+
Process one or more files; this is the default action and may be omitted.
if [ "$TEXROOT" == "" ]; then
 
# setup ConTeXt’s path; I used different locations on OSX and Linux
 
# You might also check on the hostname or if the path exists
 
if [ "$OS" == "Linux" ]; then
 
source /var/opt/context/tex/setuptex /var/opt/context/tex
 
elif [ "$OS" == "Darwin" ]; then
 
source ~/Library/texmf/tex/setuptex ~/Library/texmf/tex
 
fi
 
fi
 
  
# ulimit was 256 on older OSX versions, that's too low for bigger books
+
== --autopdf ==
if [ `ulimit` != "unlimited" ]; then
 
ulimit -S -n 2048
 
fi
 
  
# I like to have my PDFs versioned at least by date
+
Reopen the generated PDF file in the system's default PDF file viewer after recompiling a document.
ISODATE=`date +"%Y-%m-%d"`
 
  
PRD=$1
+
== --purgeall ==
if [ "$1" == "" ]; then
 
echo Which product?
 
ls -Alh prd_*.tex
 
exit 1
 
fi
 
RESULT=${PRD}_${ISODATE}
 
  
MODE=$2
+
Delete all build artifacts generated during compiling of a document, such as ''.tuc'' and ''.log'' files.
if [ "$MODE" == "" ]; then
 
echo Using lowres pictures for preview. Use 'print' parameter for highres mode.
 
MOD=lowres
 
else
 
# print
 
RESULT=${RESULT}_$MODE
 
fi
 
  
if [ "$OS" == "Darwin" ]; then
+
== --path=list ==
OPEN='open -a Preview'
 
SHARE=~/Box
 
else
 
OPEN="qpdfview --quiet"
 
SHARE=~/Dropbox
 
fi
 
  
context --jit prd_${PRD} --result=_pdf/$RESULT --mode=$MOD
+
Provide a list of paths for ConTeXt to search when processing.
if [ "$?" == "0" ]; then
 
${OPEN} _pdf/$RESULT.pdf &
 
cp _pdf/${RESULT}.pdf ${SHARE}/projects/
 
fi
 
  
</pre>
+
== --result ==
  
 +
Changes the output document file name. ConTeXt creates the output document file in the current working directory; this option cannot create or move the output document in a different directory. Instead, change the working directory before running ConTeXt and use the ''--path'' option to configure where ConTeXt searches for files to process.
 +
 +
 +
 +
[[Category:Basics]]
 
[[Category:Tools]]
 
[[Category:Tools]]

Revision as of 02:13, 31 March 2021

The First Document page provides a cursory introduction to typesetting document using ConTeXt. The Context page describes the command-line options in brief. This page provides additional information for command-line options.

--run

Process one or more files; this is the default action and may be omitted.

--autopdf

Reopen the generated PDF file in the system's default PDF file viewer after recompiling a document.

--purgeall

Delete all build artifacts generated during compiling of a document, such as .tuc and .log files.

--path=list

Provide a list of paths for ConTeXt to search when processing.

--result

Changes the output document file name. ConTeXt creates the output document file in the current working directory; this option cannot create or move the output document in a different directory. Instead, change the working directory before running ConTeXt and use the --path option to configure where ConTeXt searches for files to process.