.TH mk 1 "July 14, 2025" "mk version 3.10" "DekDoc scripts" .SH NAME mk - a TeX and LaTeX maker .SH Synopsis .B mk [options] [file] .SS General options: .B -h,--help .RS .B print this help and exit .RE .B -H,--Help .RS .B print full documentation via less and exit .RE .B -V,--version .RS .B print version and exit .RE .B -v,--verbose .RS .B be verbose .RE .B --noverbose .RS .B be quiet (this is the default) .RE .B -r,--rc=X .RS .B set rc file to X, but this must be the first option! .RE .RS .B If X is absent, don’t read any rc file. .RE .B -n,--nocolor .RS .B no coloring instead of ANSI .RE .SS mk specific options: .B -f,--formatter=X .RS .B Use X as the formatter: tex, latex, pdflatex, .RE .RS .B et cetera .RE .B -e,--edit=X .RS .B use X as the file to be edited; by default, the file .RE .RS .B file. .RE .B -C,--Clean .RS .B Remove all files generated by the compilation .RE .B -c,--clean .RS .B Same, except for the pdf or postscript files .RE .SS vpp-related options: .B -b,--batch=X .RS .B run in batch using X as a printing command for vpp. .RE .RS .B information. .RE .B -p,--printer=X .RS .B print to printer named X .RE .B --view .RS .B view the document after compilation .RE .B --noview .RS .B do not view .RE .B --print .RS .B offer printing interaction after viewing .RE .B --noprint .RS .B do not offer printing interaction .RE .SS Defaults: --print --view --noverbose main .RE Arguments for short options are given without a separator, so you can write either --rc=myrc or -rmyrc. .SH Description mk is a Bash script that, in close collaboration with vpp (short for View and Print PDF/PostScript), is helpful in the cyclic process of editing, compiling, viewing, and printing a tex document. Essentially, mk uses texi2dvi (ctan.org\fItex-archive\fRmacros\fItexinfo\fRlatest) for compilation, vpp (www.ctan.org\fIpkg\fRvpp) for viewing and printing. Any TeX formatter can be handled, with the exception of those starting with ht (such as httex and htlatex) and context (handle those with texexec). Having an existing TeX document, say main.tex (see the section \fILocating the source\fR for the creation of new documents and for other extensions than .tex), you run mk by typing: $ mk main or, since \fImain\fR happens to be mk´s default filename: $ mk Now, if main.tex is a valid TeX source, mk compiles it, including any table of contents, indices, bibliography references, included files, and so on, and \fIvpp\fR takes over and displays the resulting \fIPDF\fR or \fIPostScript\fR output. When you leave the viewer you will see a prompt: vpp command (h for help): If you are satisfied with the displayed output, you can now decide to print all or part of your document (see the section \fIPage selection\fR), or you can simply quit by typing 'q'. On the other hand, if you decide that you want to change the source and have another try, you can edit the source by typing 'e' to get back to mk and (re)edit your source. After saving your work and leaving your editor, another compilation and display cycle will be performed, based on the new source. If the compilation results in an error, the eror wil be displayed by the texlog_extract script, and you will be prompted with: =====> e(dit) c(ompile) q(uit) giving you the opportunity to e(dit) the source, after which it will be recompiled, or to c(ompile) it again (because you may have editied it in another window), or just to quit. Essentially, mk uses \fItexi2dvi\fR for compilation. \fItexi2dvi\fR always runs TeX at least once, even though this may be unnecessary. Therefore, TeX will be run with the --recorder option, which reports all the target´s dependencies in a .fls file. In every cycle, mk analyzes the .fls and the tex and bibtex .log files to see if a compilation is needed. When errors have occurred, mk uses the log files to find out which file has to be edited, and at which line. This can also be a file read with \\input, a style file, or any other file on which the target depends. However, files in the TEXMFMAIN tree are excluded. .SH Editor vpp uses the contents of environment variable EDITOR to find your editor. If that variable is empty, \fIvim\fR is used. Note that your editor should not fork off your shell, so if you specify \fIgvim\fR, for example, specify it with the option --nofork. .SH Page selection As said in the introduction, after a successful compilation and display of the resulting \fIPDF\fR or \fIPostScript\fR output, the user is prompted with: vpp command (h for help): on typing 'h' \fIvpp\fR displays examples of possible commands: Examples of print commands: 5 to print page 5 5- to print pages 5 through the end 5-7 to print pages 5, 6 and 7 7-5 ox write pages 7, 6 and 5, in that order, to x.pdf -7 to print the first 7 pages 5-7 19- to print pages 5, 6, 7 and 19 through the end a to print the whole document - to print the whole document a x3 to print 3 copies of the document x3 the same 5 x3 to print 3 copies of page 5 s print the whole document single-sided s 2- print single-sided starting at page 2 b to print the whole document as an a5 size booklet b -12 to print the first 12 pages as an a5 size booklet Other commands: e edit the tex source and rerun mk c rerun mk with forced compilation v (re)view the ps/pdf file w list errors and warnings from the log file oxyz send pdf output to file xyz.pdf instead of printer pxyz print to printer xyz h display this help ? display this help q quit With these examples, no further explanation should be necessary, except that, when two sided (t) or booklet (b) printing is selected for a single- sided printer, printing will be performed in two shifts, one for the front side and one for the backside. Between the shifts, another prompt appears: printer ready? then turn stack and type return You will have to arrange your printer such that, with the printed sides up, the first page printed will be at the bottom of the stack, and the last page printed will be on top. Normally you will then have your output come out the back of your printer. 'Turn the stack' then means: rotate it over the long side of the paper and feed it back into the printer for the other side to be printed. For further information on \fIvpp\fR, look in its manpage by typing $ vpp --help or read the \fIvpp\fR documentation. .SH Locating the source .IP ‣ 2 If you supply no arguments, the file main.tex in the current directory is assumed. .IP ‣ 2 If you supply an argument (say \fImyfile\fR), mk adds a .tex extension if it isn´t there and looks for myfile.tex in the current directory. .IP ‣ 2 If myfile.tex is not found in the current directory, mk looks in the 'alternate directory' (say /Docs) if you have defined one (see the section 'RC files'). .IP ‣ 2 If the source was not found in /Docs, mk thinks that you may have a subdirectory \fImyfile\fR in /Docs where the source may live under the name main.tex .IP ‣ 2 If that file is not there, mk now concludes that the source does not yet exist and reports this, telling at the same time which files have been tried. .IP ‣ 2 Finally, if all the above did not lead to a source file, mk dies. .SH The TeX formatter to be used mk determines the TeX formatter needed to compile the source as follows: .IP ‣ 2 if the --formatter option was used, its argument will be used; .IP ‣ 2 if the first line of the source starts with %!, the rest of that line specifies the formatter; for example: .PP %!xelatex .IP ‣ 2 if the --formatter option was not used and the first line does not start with %!, mk looks for a \\usepackage{fontspec} or \\RequirePackage{fontspec} and, if found, uses \fIlualatex\fR. Those calls may have options, but they must be on the same line. .IP ‣ 2 if still no decision could be made, mk looks for \\documentclass and chooses \fIpdflatex\fR; .IP ‣ 2 finally, if no match was found, \fIpdftex\fR is assumed. .PP .SH Running in batch mode If you don´t need to edit the source and to view the output, but just want to compile and maybe print the result, the --batch option is useful. The --batch=command option prevents mk display the output and to interrogate the user about pages to be printed. Instead the document is printed according to the mandatory \fIcommand\fR, which mus be quoted if it contains spaces. Thus the command mk --batch='2-3 x3' test prints 3 copies of pages 2 and 3 of test.tex, without viewing. If you just want to compile without printing anything, use the q command: mk --batch=q test or mk -bq test .SH RC file and customization Unless the option --rc has been used, the file ~/.mkrc will be sourced, if it exists, before reading the command line options. You can use this rc file to set the default values for the options, by setting the global shell variable named after the long version of the options. For example: verbose=true # run in verbose mode So if you usually like mk to work in verbose mode, you can indicate so in your rc file and change your mind in some cases by using the --noverbose option. Other variables, not having a corresponding command line option, that can be set in the rc files, and their default values, are: .B EDITOR= .RS sets your editor; You can also set your EDITOR in your system startup files. Note that your editor should not fork; so if you set it to gvim, do: .RE .RS .B EDITOR='gvim --nofork' .RE .B extraoptions= .RS adds one or more extra options to the \fItex\fR (\fIlatex, xelatex\fR et cetera) command. Example: extraoptions='-shell-escape␣-quiet' .RE .B othercleans= .RS can be set to a file regular expression; in the cleaning operation, caused by the --clean option, this variable will be eval'ed, and the resulting files will be removed. This is useful, for example, when the gnuplottex package is used; this package generates intermediate files named $base-gnuplottex-fig*, where the variable $base contains the basename (without extension) of your tex source file. So after adding: .RE .RS .B othercleans='$base-gnuplottex-fig*' .RE .RS to your ./mkrc file, the cleaning operation will get rid of these files, too. .RE .B texi2dviquiet=false .RS Normally, in verbose mode, you also see the complete tex log output, because \fItexi2dvi\fR will be verbose, too. This obscures most other output. You can keep \fItexi2dvi\fR quiet in verbose mode by setting this variable to true: .RE .RS .B texi2dviquiet=true .RE .B skip_pattern= .RS can be set to a file wild card pattern. Files matching this pattern on which the \fI(la)tex\fR source file may depend will not be checked for changes. For example, if you use a write-protected TeX-tree in the directory mytextree it makes sense to set skip_pattern=mytextree unless you set skip_pattern explicitly, it will be set to match the TEXMFMAIN tree. .RE .B altdir= .RS If altdir is non-empty and a file to be compiled does not exist in the current directory, it will be given another try after prefixing it with the contents of altdir. So if you like to have your LaTeX file in /Docs/myfile.tex you can set altdir to /Docs and run mk from any directory with: .RE .RS .B $ mk myfile .RE .RS However, a directory like /Docs does not make much sense if many of your LaTeX documents do not consist of a single file, but are constituted of an ensemble of a main LaTeX source and one or more files read with \\include or with \\input such as graphics. You will then probably prefer to have a subdirectory in /Docs for every LaTeX document. Therefore, if mk does not find myfile.tex in the alternate directory, it will assume that \fImyfile\fR is a subdirectory with a main LaTeX source in it, called main.tex. .RE .B default=main .RS This is the default for the base name of your LaTeX document. .RE .B warnings_to_skip=() .RS Warnings appearing in the log file will be reported after a successful run. Warnings matching any of the regular expressions in this array will be skipped, however. For example, one could enter here: .RE .RS .B warnings_to_skip=( .RE .RS .B 'Package hyperref Warning: Token not allowed' .RE .RS .B 'Package array Warning: Column [XY] is already defined' .RE .RS .B ) The first message appears when the \fIhyperref\fR package is used and section titles contain LaTeX-commands, the second message appears when the \fIctable\fR package is used, because it intentionally changes the X and Y column specifiers. .SH TeXWorks and mk mk can be used for one-click typesetting: .IP ‣ 2 edit -> preferences -> Typesetting .IP ‣ 2 add a new tool mk and give it three parameters: .PP --preview --nocolor $basename .IP ‣ 2 Deselect "Auto-hide output panel unless errors occur" .IP ‣ 2 If you need an other formatter than the default, pdflatex, use the %! line in your source, or define separate tools in TeXWorks with an extra --formatter=... parameter. .PP mk runs pdflatex with the --synctex=1 option, so you will be able to jump between source and pdf-ouput. .SH Bugs .IP ‣ 2 If, during the compile-edit-cycle, the %! line is changed, mk should respond to it by changing the formatter. .IP ‣ 2 Currently, mk is only available for Linux. It depends on \fItexi2dvi\fR. Spaces in the basename of TeX sources are not allowed (neither does the \fItexi2dvi\fR script on which mk is based.) .SH Author Wybo Dekker (wybodekker@me.com) .SH Copyright Released under the GNU General Public License (www.gnu.org\fIcopyleft\fRgpl.html)