IntroductionConTeXt, because TeXinfo, Muse and LaTeX are not the best tools for writing/creating books, papers, flyers, booklets, reports, magazines, theses, etc. these days. TeXinfo is great when it comes to write manuals for FLOSS (Free/Libre Open Source Software). Muse is awesome to have your website done with (which happens to be a Wiki in most cases). LaTeX is kind of outdated although I happily used it for years and still think it is a great tool set. However, the above words are my current point of view. They are therefore totally biased and subjective. Others might have other opinions on the matter which is of course perfectly fine... In general, there is nothing like The best tool is... — all of the afore mentioned tools have their strengths and weaknesses depending on what task at hand. Why ConTeXt?As we already know, ConTeXt is basically just another TeX distribution — I have been with LaTeX and TeXinfo before. I used LaTeX to create both of my master theses among many other documents. Pretty much at the same time I started to use TeXinfo. TeXinfo is quite cool when it comes to have one source file and the need to create several output formats from it e.g. XHTML, PDF, GNU Info, etc. Then after a while I discovered Muse — which is what I use for this website/platform. Anyway, some time ago, I was confronted with the task to write a series of technical papers for some clients in the financial sector. What tool should I use? LaTeX nor TeXinfo seemed quite right at this time. LaTeX would be all right since I needed to deal with mathematical formulas a lot but then there are those nasty package clashes that I am tired off. So, no LaTeX. Also no TeXinfo since formulas with TeXinfo... well, I have been there... still hurts... simply a no-go. As for TeXinfo, Muse is a no-go in case one needs heavy mathematics in his document. I also needed something to create some funky graphics and a nice-looking, professional layout So?... OpenOffice?... Not really. Real man do not use the mouse ;-]
Well, long story made short — ConTeXt provides me with no headache because of dump package clashes, has a modern concept (compared to LaTeX), allows for formulas which turn our brains upside down and ships with the power of Metafun i.e. mind-blowing layout at our fingertips. Attitude and QualityLast but not least, anyone serious about writing a book will find nothing better than ConTeXt to do so. However, please note, ConTeXt is a technology — nothing more, nothing less. Although smart, powerful and accurate, the outcome can just be as good as is the human part and the technology part taken together — if one of them is crap, the outcome will certainly be crap too. What that means is obvious: I have seen Professors writing papers and theses using Open Office respectively Microsoft Word. Well, as one would expect, the result pretty much was crap — maybe not so much from the contents point of view but certainly from the layout point of view — in the end, content always suffers from bad layout too, at least that is my experience. I have also seen unskilled/inexperienced/dump/lazy students writing their papers/theses with LaTeX, they too produced crap. As the heading says, being serious about getting into the heavens of professional typesetting takes time. Those who are new to the whole matter of professional typesetting and thus some tool that actually allows to do so (and no, Microsoft Word, OpenOffice and friends do not belong to this group) and think they might produce mind-blowing results after 2 weeks... well, then better stick to OpenOffice or even worse, Microsoft Word because great results after 2 weeks... not going to happen!
Book design is the art of incorporating the content, style, format, On the other hand, if the reader is more the kind of person who approaches things from the academic angle i.e. reading around for a few weeks, testing and trying for another month, getting a feeling for the things and starting all over the right way three months after first contact, then ConTeXt is for him. Even more so if he finds it great to learn new things and mind-boggling stuff after already using it for 2 years on a regular...
As I have said, I tried pretty much anything out there, wrote books, master theses, PhD thesis (yet to be written), articles, reports and whatnot. ConTeXt is the best I came across so far. I think I am pretty good settled when I say, I am going to use ConTeXt for anything book, report, article, folder, thesis like... i.e. whenever superior typesetting, layout, graphics and formulas are needed. TeXinfo for all the FLOSS (Free/Libre Open Source Software) stuff i.e. a lot of screen dump with examples from the CLI (Command Line Interface) etc. and Muse for my blog, website and PIM (Personal Information Manager) because of its great wiki-like feeling. Sorry LaTeX, we had our time and it was nice but you are just to old for a young and handsome guy like me ;-] Getting StartedThis section is about how to get started. Of course I use GNU Emacs to write my ConTeXt documents. Emacs has a mode called AucTeX which can be used to create LaTeX, ConTeXt etc. documents. Those who are already familiar with AucTeX know that Emacs mode is mind-blowing. Note that there are many editors that can produce ConTeXt code — however, as always, Emacs is superior over any other. Acquiring the SoftwareWe need to get ConTeXt itself plus (just in case we are going to use GNU Emacs) AucTeX and Emacs itself. That said, for the sake of completeness it also has to be said that basically any text editor can be used to create ConTeXt source code i.e. GNU Emacs is not obligatory but I strongly recommend it. ConTeXtOn DebianGNU/Linux all we need to do is to install a few packages sa@wks:~$ dpl {auctex,context} | grep ^ii ii auctex 11.83-7.1 integrated document editing environment for TeX etc. ii context 2008.01.28-1 powerful TeX format sa@wks:~$ i.e. GNU EmacsThose who have not installed GNU Emacs yet might install it. There are many ways to do so. One way to have an up-to-date GNU Emacs all the time with pretty much no effort at all is to put the following entry in ,----[ grep emacs /etc/apt/sources.list ] | # emacs snapshot | deb http://emacs.orebokech.com sid main | deb-src http://emacs.orebokech.com sid main `---- and then install a few packages sa@wks:~$ dpl emacs* | grep ^ii ii emacs-goodies-el 29.2-1 Miscellaneous add-ons for Emacs ii emacs-jabber 0.7.1-4 Jabber client for Emacsen ii emacs-snapshot 1:20080406-2 The GNU Emacs editor (development snapshot) ii emacs-snapshot-bin-common 1:20080406-2 The GNU Emacs editor's shared, architecture ii emacs-snapshot-common 1:20080406-2 The GNU Emacs editor's common infrastructure ii emacs-snapshot-el 1:20080406-2 GNU Emacs LISP (.el) files ii emacs-snapshot-gtk 1:20080406-2 The GNU Emacs editor (transitional package) ii emacsen-common 1.4.17 Common facilities for all emacsen Customizing GNU EmacsFinally we need some .emacs magic to make writing ConTeXt documents a
joy like nothing else... Generally, reading the AucTeX Info manual is
a good start anyway I am not going to explicitly provide and explain stuff here since my .emacs does it anyway plus this way it is ensured the information is always up-to-date. Just look out for the [skipping a lot of lines...] ;;;_ Document Engineering ;;;_. auctex ;;;_ , initialize some stuff (load "auctex.el" nil t t) (load "preview-latex.el" nil t t) (setq TeX-auto-save t) (setq TeX-parse-self t) (setq TeX-auto-untabify t) (setq TeX-display-help t) (setq TeX-save-query nil) (setq TeX-clean-confirm nil) (setq-default TeX-master nil) ;;;_ , hook(s) (add-hook 'TeX-mode-hook (lambda () (TeX-fold-mode 1))) (add-hook 'TeX-mode-hook (lambda () (TeX-source-specials-mode 1))) (add-hook 'TeX-mode-hook (lambda () (TeX-toggle-debug-bad-boxes))) (add-hook 'TeX-mode-hook (lambda () (TeX-toggle-debug-warnings))) (add-hook 'TeX-mode-hook (lambda () (outline-minor-mode))) (add-hook 'TeX-mode-hook (lambda () (abbrev-mode t))) (add-hook 'TeX-mode-hook (lambda () (auto-fill-mode 1))) (add-hook 'TeX-mode-hook 'LaTeX-math-mode) ;;;_ , etexshow (autoload 'etexshow "etexshow" "Browswer for ConTeXt commands." t) (setq etexshow-xml-files-alist `((,(concat emacs-root-dir "libs/etexshow/cont-en.xml") . ,(concat "/tmp/cont-en.cache")))) (setq etexshow-comment-file (concat emacs-root-dir "libs/etexshow/cont-en-comments.xml")) ;;;_. doc-view (setq TeX-PDF-mode t) (setq revert-without-query '(".+pdf$")) (add-hook 'doc-view-mode-hook 'auto-revert-mode) [skipping a lot of lines...] part. Also, note StructureWriting some report, article, magazine, book etc. always boils down to how to structure information. Before we start thinking about a decent project structure we have to step back one further step and take a look at the big picture. A prerequisite to create a decent project structure — making use of a technology in order to map ones thoughts into something others can pick up — is to get the overall picture of the whole process. Here is what needs to be done:
General Document StructureThis section tells about what I do in chronological order. From the link above we know that we need to know how to write a book/document first.
A document will be divided in functional components like introductions and appendices Before we actually go into detail on the document structure we should know that there are several approaches depending on objective things like what kind of document is going to be written or other, more subjective, reasons like for example the personal likings of some author. More information on that matter can be found in chapter 8 of this manual. Step 1 - The LayoutAt first I think about the layout:
Mostly, what influences this decicision is the supposed readership and the writings purpose — a doctoral thesis has a different layout than a 90 pages business plan. And of course those two a have a totally different layout compared to some booklet or an event flyer for some vernissage. Step 2 - The front matterThe front matter consists of all or just a few of the following parts:
Of course, a flyer might not have any of the front matter parts. A book on the other hand might come with all of the above and a very detailed technical report might also have almost all of the front matter parts included but might have a little bit of a different naming for them e.g. what is called Prologue with a book might be called
Sounds complicated? Yes, a little bit for those who are entirely new to the matter of how to create an outstanding piece of writing — something that deserves to be read by others, something that is not just wasting the most valuable thing (time) a living organism possesses and something that makes people forget about time and space, lets them disappear from their environment with something in their hands called a book. As it can be seen, one might really lean back, take a deep breath and provide himself with some ambiental space that suits the situation (music, tea, landscape, etc.) in order to acquire that new knowledge. Rushing through this phase would result in producing crap... We do not want that nor are we satisfied with creating average work — we want to climb on top of the things possible no matter what! Antonio Vivaldi's violin concerts and a cup of green tea with ginger help (me) a lot with such undertakings. Step 3 - The bodyThis part is easy to understand and I would guess anyone ever written anything more than a flyer is already familiar with the Body of some writing. The Body matter usually includes:
Of course, a flyer or booklet might not be build from any of these structural items at all. A flyer for example might just be one sheet of paper. A booklet might have around 5 pages and therefore could already have parts. For example, let us assume we are creating a booklet which is an invitation for some business dinner. It has three parts — 1) who is the host and why is it happening, 2) what will the evening program be and last but not least, 3) a description of the location and how to get there. The more experienced folks and/or the attentive reader might also think by himself... Well, I know there are parts, chapters, sections, etc. but how do I split the things to be written among them? This is a gvery good question! We talk about that later on in phase 2... Step 4 - The back matterAs for the front matter, not anyone might be an expert on this structural part of document e.g. book, magazine, etc.
As for the front matter and the body part — a book might contain all the upper listed items but other writings might just have a subset or maybe even none of the back matter items listed above. Structuring the InformationHa! That one is easy... Why? Well, because anything said about this phase is wrong and right at once — there are absolutely no generic rules — just per-person opinions. The outcome of this phase depends on the information itself, the individual and its point of view, the society an individuals lives in, current scientific facts, etc. However, here is what I do: My rationale about how to approach this issue is mainly dependant on the type of knowledge and the type of document I am writing. The way I figure it makes sense to structure the information is actually trivial and therefore ingenious at once:
One-dimensional Examples
Two-dimensional Example
Project StructureThis is where we actually make first contact with the technology we are going to use — during phase 1 and 2 nobody needs to take care about the technology that will finally be used to create a document!. The image below shows what is a typical ConTeXt project structure:
Further down we will see how to create such a project structure starting with the project files (Project and Environment). After the project files we create the product files and after those have been created the last thing to do is to create the component files. Any of those files is a plain text file and can be edited with any editor of choice e.g. GNU Emacs. Ultimately, roughly speaking, the whole text also known as information of some project (i.e. the stuff people will read in the printed PDF) will live within the component files and the representation i.e. document's layout will live within the environment file. The product files are mainly to structure the information/document into logical coherent parts. Why using a Project Structure?Well, first of all we already discussed that above. Secondly, because this is very useful since we can reuse parts e.g. the environment which is responsible for the layout — yes, as many others, ConTeXt follows the principle of separating information and representation. Same as with XHTML (Extensible HyperText Markup Language) and CSS (Cascading Style Sheets). Helper ScriptI found a nice little helper script on the net which eases things a lot #!/usr/bin/perl -w use warnings; print "Make ConTeXt project -- 2002-05-17\n"; print "copyleft 2002 Henning Hraban Ramm\n"; print "Thankfully adopted by Markus Gattol, Mai 2008\n\n"; @Level = ("environment", "project", "product", "component"); @Prefix = ("envi_", "proj_", "prod_", "comp_"); # file prefixes $Suffix = ".tex"; # ending $IniSuffix = ".ini"; # ending for defaults files $Command = $ARGV[0]; if (!$Command) {$Command=".";} $validCommand = 0; $ProjectPath = "."; # default path = actual path if ($Command =~ m/^--/) { # if first parameter starts with -- $Command =~ s/^--//; # delete -- ($Command eq "help") && help(); # show help, if wanted if ($Command =~ m/[0-3]/) { $Command = $Level[$Command]; } # if --0 etc. for ($count=@Level-1; $count>0; $count--) { # iterate all levels if ($Command eq $Level[$count]) { # if command matches level unless ($ARGV[1]) { # if no second command line parameter my $missname = $Level[$count-1]; if ($missname eq $Level[0]) { $missname = $Level[1]; } help("$missname name is missing!"); } # if no second parameter if (($count>1) and (!$ARGV[2])) { # with level 2 we need 2 parameters help($Level[$count]." name is missing!"); } # if no third parameter $validCommand=1; # ok, print no help print "making ".$Level[$count]."...\n"; MakeFile($count, $ARGV[1], $ARGV[2]); } # if } # for ($Command eq "all") && help("option --all is not yet implemented.\n"); ($validCommand) && exit(0); # exit without error } # if --parameter help("Don't know what to do!"); # help function ends with exit ### END ### sub MakeFile { # gets level number and two other args (project/product or product/component) ### my $ActLev = $_[0]; my $ProjectName=$_[1]; my $ProductName=$_[2]; my $InKey=""; my $ProjectLine=""; if ($ProjectName =~ m/^.*[\/\\:]/) { # look for folder delimiters $ProjectName = $'; # ' chop($ProjectPath = $&); $ProjectPath =~ tr§\:\/\\§/§; # change all delimiters to UNIX slashes } # if if (ProductName =~ m/^.*[\/\\:]/) { # delete other path $ProductName = $'; # ' } if (!$ProductName) { $ProductName=$ProjectName; } unless (-d $ProjectPath) { # test path (-f $ProjectPath) && die "$ProjectPath is a file!\n"; print("making $ProjectPath..."); mkdir($ProjectPath) or die "Cannot make dir $ProjectPath: $!"; } # if no path $FileName = $ProjectPath."/".$Prefix[$ActLev].$ProductName.$Suffix; (-d $FileName) && die "$FileName is a directory!\n"; # Insert entry in next level file if ($ActLev > 1) { # insert product and component into next level my @FileList = (); my $Count = 0; $ProjectFileName = $ProjectPath."/".$Prefix[$ActLev-1].$ProjectName.$Suffix; print "Inserting ".$Prefix[$ActLev].$ProductName." into ".$Level[$ActLev-1]." ".$ProjectFileName."...\n"; open (myFILE, $ProjectFileName) or warn "Cannot open $ProjectFileName: $!"; while (<myFILE>) { $FileList[$Count] = $_; if (($ActLev==3) && (m/\\project/)) { # if component $ProjectLine = $_; } # if component and project line in product file if (m/\\stop$Level[$ActLev-1]/) { $StopPos = $Count; } if (m/$Prefix[$ActLev]$ProductName/) { $Exist = 1; print "Entry exists already.\n"; } $Count++; } # while myFILE close (myFILE); if (!$Exist) { open (myFILE, ">".$ProjectFileName) or warn "Cannot open $ProjectFileName: $!"; for ($Count=0; $Count < @FileList; $Count++) { if ($Count == $StopPos) { print myFILE "\t\\".$Level[$ActLev]." ".$Prefix[$ActLev].$ProductName."\n"; } # if StopPos print myFILE $FileList[$Count]; } # for close (myFILE); } } # insert product and component into next level # Make this level file if (-f $FileName) { print "$FileName exists. May I overwrite it? (YJ/N, Return)\n"; while ($InKey !~ m/[JYN]/i) { $InKey= ""; print "?"; $InKey = getc; } # while } # if file exists $IniFile = $Level[$ActLev].$IniSuffix; # defaults for every level if ($InKey !~ m/N/i) { print "Making $FileName...\n"; open (myFILE, ">".$FileName) or die "Cannot make $FileName: $!"; ($ActLev == 1) && print myFILE "% output=pdf interface=en\n"; print myFILE "\\start".$Level[$ActLev]." ".$Prefix[$ActLev].$ProductName."\n"; if (!$ActLev) { $tempLev=1; } else { $tempLev=$ActLev-1; } print myFILE "\\$Level[$tempLev] ".$Prefix[$tempLev].$ProjectName."\n"; ($ProjectLine) && print myFILE $ProjectLine; print myFILE "\n"; if ($ActLev==1) { print myFILE "% \\showlayout\n"; print myFILE "% \\showgrid\n"; print myFILE "% \\showbodyfontenvironment\n"; } # if project if (-f $IniFile) { # look for .ini file in script dir open (iniFILE, $IniFile) or warn "Cannot open $IniFile: $!"; print "inserting $IniFile into $FileName...\n"; while (<iniFILE>) { print myFILE;} # while close (iniFILE) or warn "Cannot close $IniFile: $!"; } $IniFile = $ProjectPath."/".$IniFile; if ((-f $IniFile) && ($ProjectPath ne ".")) { # look for .ini file in project dir open (iniFILE, $IniFile) or warn "Cannot open $IniFile: $!"; print "inserting $IniFile into $FileName...\n"; while (<iniFILE>) { print myFILE;} # while close (iniFILE) or warn "Cannot close $IniFile: $!"; } print myFILE "\n"; print myFILE "\\stop$Level[$ActLev]\n"; print myFILE "\n"; close (myFILE) or die "Cannot close $FileName: $!"; } # if InKey not N ($ActLev == 1) && MakeFile(0,$ProjectPath."/".$ProjectName,$ProductName); # project makes environment } # sub MakeFile ### sub help { ### ($_[0]) && print "ERROR: $_[0]\n\n"; print "Syntax: makeproject --help\n"; print " will give this help\n\n"; print "......: makeproject --project <projectname>\n"; print " will make $Prefix[1]<projectname>$Suffix and $Prefix[0]<projectname>$Suffix\n\n"; print "......: makeproject --product <projectname> <productname>\n"; print " will make $Prefix[2]<productname>$Suffix and add it to $Prefix[1]<projectname>$Suffix\n\n"; print "......: makeproject --component <productname> <componentname>\n"; print " will make $Prefix[3]<componentname>$Suffix and add it to $Prefix[2]<productname>$Suffix\n\n"; # print "......: makeproject --all <productname>\n"; # print " will make all of the files, asks after names\n"; print "Path should be only in first name!\n"; exit(1); } # sub help After reading and downloading the script called Creating a Project Structure with
|