% ------------------------------------------- % latex generated by: booktolatex.cgi % from source file : ../htdocs/books/linux-document/linux-document-book.txt % on: 19 April 2024, 7:43am % querystring: books/linux-document/linux-document-book.txt % document-root: /var/www/html % script-name: /cgi-bin/booktolatex.cgi % Server-name: bumble.sourceforge.net % Sed-script: booktolatex.sed % ------------------------------------------- \documentclass[a4paper,12pt]{article} \usepackage[margin=0.4cm,noheadfoot]{geometry} \usepackage{color} %% to use colours, use "xcolor" for more \usepackage{multicol} %% for multiple columns \usepackage{keystroke} %% for keyboard key images \usepackage[toc]{multitoc} %% for multi column table of contents \usepackage{tocloft} %% to customize the table of contents \setcounter{tocdepth}{2} %% only display 2 levels in the contents \setlength{\cftbeforesecskip}{0cm} %% make the toc more compact \usepackage{listings} %% for nice code listings %\lstset{language={}, \lstset{language=bash, %% define special comment delimiters '##(' and ')' moredelim=[s][\color{grey}\itshape\footnotesize\ttfamily]{~(}{)}, basicstyle=\ttfamily, %% fixed pitch font xleftmargin=1cm, %% margin on the left outside the frames breaklines=true, %% break long code lines breakatwhitespace=false, %% break long code lines anywhere breakindent=10pt, %% reduce the indent from 20pt to 10 postbreak=\mbox{{\color{blue}\small$\Rightarrow$\space}}, %% mark with arrow showstringspaces=false, %% dont show spaces within strings framerule=5pt, %% thickness of the frames rulecolor=\color{lightgrey}, frame=l} %% source code settings \usepackage{graphicx} %% to include images \usepackage{fancybox} %% boxes with rounded corners \usepackage{wrapfig} %% flow text around tables, images \usepackage{tabularx} %% change width of tables \usepackage[table]{xcolor} %% alternate row colour tables \usepackage{booktabs} %% for heavier rules in tables \usepackage[small,compact]{titlesec} %% sections more compact, less space \usepackage{enumitem} %% more compact and better lists \setlist{noitemsep} %% reduce list item spacing \usepackage{hyperref} %% make urls into hyperlinks \hypersetup{ %% add "pdftex," if only pdf output is required colorlinks=true, %% set up the colours for the hyperlinks linkcolor=black, %% internal document links black urlcolor=black, %% url links black filecolor=red, citecolor=red, bookmarks=true, pdfpagemode=UseOutlines} % define some colours to use \definecolor{lightgrey}{gray}{0.70} \definecolor{grey}{gray}{0.30} \titleformat{\section}[frame] %% titlesec: create framed section headings {\normalfont} {\filleft \footnotesize \enspace Section \thesection\enspace\enspace} {3pt} {\bfseries\itshape\filright} \title{Writing and Publishing with Linux} \author{} \date{27 October 2011, 6:33pm} \setlength{\parindent}{0pt} % \setlength{\parskip}{1ex} % label lists with stars \renewcommand{\labelitemi}{$\star$} \begin{document} \centerline{\Large \bf Writing and Publishing with Linux} \medskip \begin{center} {\huge ``}\textit{}{\huge ''} \textsc{} \end{center} % ----------------------------------- % the toc should be 2 columns because of the \multitoc package \tableofcontents \begin{multicols}{2} \begin{lstlisting} MARKDOWN The markdown system uses a minimalist structured text format to produce html. 'markdown' is both a 'text format' and also a perl script used to turn that format into html. Using pandoc it is possible to convert markdown formatted text into other formats, such as pdf. Markdown may fill a gap between enscript and latex, where the user wants more control over how the produced document looks than can be obtained with 'enscript', but doesnt wish to become mired down in the complexities of 'latex' @@ http://daringfireball.net/projects/markdown/ details about the format of the source document (text file). @@ http://daringfireball.net/projects/markdown/dingus a page to actually try out markdown text syntax @@ http://six.pairlist.net/pipermail/markdown-discuss/ the markdown discussion list archives CONVERTING TO HTML .... The 'markdown' perl script can only create html but 'pandoc' can produce other formats from the same markdown source text document. Markdown only seems to produce a 'fragment' of html (without head and body tags) * display a text document converted to html with markdown >> markdown document.txt | less * convert a document to html and save as 'doc.html' >> markdown doc.txt > doc.html * convert a document and add html and body tags to make a complete page >> (echo '';markdown doc.txt;echo '') > out.html >> markdown doc.txt|sed '1s/^//;$s.$..' > out.html >> pandoc -s -o out.html doc.txt ##(the same but better, using pandoc) MARKDOWN SYNTAX .... The great advantage of markdown syntax is that the source document can be kept 'clean' without distracting or ugly markup codes. Normal html can be inserted anywhere in a markdown document. If there is anything which markdown cannot do (such as tables) just use html tags instead. DOCUMENT HEADINGS .... * create a 1st-level document heading (underline the text with '=' equals) \begin{lstlisting} The Heading =========== \end{lstlisting} * create a markdown 2nd-level document heading \begin{lstlisting} A Second Level Heading \begin{lstlisting} \end{lstlisting} * markup a 3rd level document heading 'Stone Fruit' >> ### Stone Fruit * create a vim command ',ll' which underlines the current line with '-' dashes >> map ,ll yyp:s/[ ]*$// \| s/[ ]*$// \| s/[^ ]/-/g \| s/- /--/go ##(place in 'vimrc'. This mapping helps to write markdown 2nd level headings) * create a vim command ',LL' which creates a markdown 1st level heading >> map ,ll yyp:s/[ ]*$// \| s/[ ]*$// \| s/[^ ]/=/g \| s/= /==/go ##(This mapping command underlines the current line with '=' equals) * create a 'blockquote', that is text more indented than surrounding paragraphs >> > ##(blockquotes can contain headings and paragraphs TEXT EMPHASIS .... * make a word or phrase emphasised >> the following is *emphasised text* >> the following is _emphasised text_ ##(more or less the same) * strongly emphasise words or phrases >> the following is **strongly emphasised text** >> the following is __strongly emphasised text__ LISTS .... The list marker can also be a '+' or a '*'. There is no difference between these types of lists * create an unordered (bulleted) list \begin{lstlisting} - first item - second item - third and last \end{lstlisting} * create an nested unordered list \begin{lstlisting} - first item * sublist item 1 * sublist item 2 - second item - third and last \end{lstlisting} * create an ordered list with a nested unordered list \begin{lstlisting} 1. First 2. Second: - Fee - Fie - Foe 3. Third \end{lstlisting} * create an unordered list with links to other parts of the page \begin{lstlisting} - [Chapter One](#chap1) - [Chapter Two](#chap2) - [Chapter Three](#chap3)

...

...

\end{lstlisting} ##(notice how normal html is used to create the anchors) * create an ordered list \begin{lstlisting} 1. first 2. second 3. third \end{lstlisting} LINKS .... * create link in a document with the display text 'example link' >> This is an [example link](http://example.com/) ##(the html: this is an example link.

) * create link with a display text and also a 'title' (when the mouse hovers over) >> [example link](http://example.com/ "With a Title") * for pdf output the embedded code backtick may look best >> `http://google.com` ##(displays the link in fixed pitch font in pdf) * create and use a named link with display text 'Google' \begin{lstlisting} a search engine is [Google][1] [1]: http://www.google.com "Google" [2]: http://www.yahoo.com "Yahoo" * create a reference link with a space in the name \begin{lstlisting} I start my morning with a cup of coffee and [The New York Times][NY Times]. [ny times]: http://www.nytimes.com/ \end{lstlisting} IMAGES .... * embedd an image file in the document, with an optional title ![a tree](/path/to/img.jpg "Title") ##(if the image is not found show 'tree') * embedd an image in the document using the 'reference' style syntax \begin{lstlisting} ![alt text][id] [id]: /path/to/img.jpg "Title" \end{lstlisting} EMBEDDED CODE .... * use backticks '`' to show code with special characters in it >> dont use the `` tag * another example >> html entities can be named `—` or numbered `—`. * use 4 spaces or 1 tab of indentation to display a paragraph of code * use a backslash to escape special characters >> \* ##(this prints an asterix) * create a horizontal rule using 3 or more dashes, asterixes etc >> --- >> * * * ##(the same) GOTCHAS .... The table dashes must begin in the 5th column all later for the table to be formatted correctly. PANDOC MARKDOWN SYNTAX .... Pandoc allows a number of extensions to markdown syntax to allow for structures such as tables. These extensions can be turned off with the '--strict' switch @@ johnmacfarlane.net/pandoc/README an example of a pandoc markdown document @@ johnmacfarlane.net/pandoc/README.html#pandocs-markdown-vs.standard-markdown details about the pandoc extensions to the markdown syntax * create subscripts and superscripts >> H~2~O is a liquid. 2^10^ is 1024. * create text P with 'a cat' superscripted >> P~a\ cat~ ##(note the escaped backslash in the superscript) * format text which is 'struck out', that is, has a bar through it >> This ~~is deleted text.~~ * create compact definition lists \begin{lstlisting} Term 1 ~ Definition 1 Term 2 ~ Definition 2a ~ Definition 2b \end{lstlisting} * single brace links (also allowed in modern markdown syntax) \begin{lstlisting} 1. Here's my [link] 2. Here's my [link][] [link]: linky.com \end{lstlisting} * inline footnotes \begin{lstlisting} Here is an inline note.^[Inlines notes are easier to write, since you don't have to pick an identifier and move down to type the note.] \end{lstlisting} * footnotes \begin{lstlisting} Here is a footnote reference,[^1] and another.[^longnote] [^1]: Here is the footnote. [^longnote]: lots of text \end{lstlisting} * create a table with a caption (use the underline to dictate the alignment) \begin{lstlisting} Right Left Center Default ------- ------ ---------- ------- 12 12 12 12 123 123 123 123 1 1 1 1 Table: Demonstration of simple table syntax. \end{lstlisting} The table dashes must start in the 5th (?) or greater column of the source text file. The table is rendered in a fixed pitch font with the dashes. * create a table with no headers \begin{lstlisting} ------- ------ ---------- ------- 12 12 12 12 123 123 123 123 1 1 1 1 ------- \end{lstlisting} A Table must end with a blank line. Multiline tables are also possible. * source code blocks (begin and end with >3 tilde '~' characters) \begin{lstlisting} ~~~ code ~~~ \end{lstlisting} * source code blocks with syntax highlighting and numbered lines \begin{lstlisting} ~~~~~~~ {.haskell .numberLines} qsort [] = [] qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs) ~~~~~~~ \end{lstlisting} Syntax highlighting may only work in html output files * show what languages syntax highlighting pandoc supports >> pandoc --version * provide document meta-information (title, author, date) \begin{lstlisting} % Small Steps % J Appleby, B Kernighan % 21/4/2001 \end{lstlisting} * html blocks within markdown documents \begin{lstlisting}
*one* [a link](http://google.com)
\end{lstlisting} * links to the document sections automatically created >> See the section on [header identifiers](#header-identifiers-in-html). * The section heading 'Green Tree' becomes [link](#green-tree) * produce a 'presentation' slide show with pandoc and 's5' % Eating Habits % John Doe % March 22, 2005 # In the morning - Eat eggs - Drink coffee # In the evening - Eat spaghetti - Drink wine pandoc -w s5 -s eating.txt > eating.html \end{multicols} \section{Pandoc} pandoc extends both the syntax of markdown (allowing tables for example) and also the number of formats to which markdown can be output, including most importantly 'pdf'. Pandoc can perform other nice tricks such as putting automatic tables of contents into documents based on the section headings. Pandoc appears to be in active development (early 2010). Features such as 'tables' are only available in later versions of pandoc. And these versions are not available as debian packages. \begin{description}[labelindent=1cm, leftmargin=2cm, style=nextline] \item[\url{http://johnmacfarlane.net/pandoc/README.html}] the good user guide for pandoc \item[\url{http://johnmacfarlane.net/pandoc/examples.html}] example of converting markdown (et al) documents to other formats \item[\url{http://groups.google.com/group/pandoc-discuss}] the pandoc discussion news group \end{description} \arrayrulecolor{gray} \begin{center} \begin{tabular}{ |rl| } \multicolumn{2}{c}{\textbf{ pandoc output formats }} \\ \hline \texttt{ HTML } & Webpages \\ \texttt{ markdown } & \\ \texttt{ LaTeX } & The tex typesetting system \\ \texttt{ groff man } & Unix manual pages \\ \texttt{ RTF } & Can be opened in ms word, for example \\ \texttt{ DocBook XML } & \\ \texttt{ texinfo } & ? \\ \texttt{ reStructuredText } & \\ \texttt{ ConTeXt } & \\ \texttt{ S5 HTML slide shows. } \\ \hline \end{tabular} \end{center} \subsection{Installing Pandoc} \emph{ Install ghc6 which is a haskell compiler. } \emph{ Install the latest pandoc using the haskell 'cabal' tool } \begin{lstlisting} cabal install pandoc \end{lstlisting} \subsection{Basic Usage} \emph{ Convert a 'markdown' text document to html format with pandoc } \begin{lstlisting} pandoc doc.txt \end{lstlisting} \begin{lstlisting} pandoc -o out.html doc.txt ~(the same, html is the default) \end{lstlisting} \begin{lstlisting} pandoc doc.txt -o out.html ~(better?) \end{lstlisting} \begin{lstlisting} pandoc -f markdown doc.txt -o out.html ~(the same, but unnecessary) \end{lstlisting} \emph{ Show what header is added to a \LaTeX{} output file } \begin{lstlisting} pandoc -D latex \end{lstlisting} \emph{ Convert multiple markdown files and a references file to an html page } \begin{lstlisting} pandoc -s ch1.txt ch2.txt refs.txt > book.html \end{lstlisting} \subsection{Converting Documents} If an output or input format is not given then pandoc will guess based on the file-names supplied. \arrayrulecolor{gray} \begin{center} \begin{tabular}{ |rl| } \multicolumn{2}{c}{\textbf{ pandoc output format (switches -t -w --to --write all equivalent) }} \\ \hline \texttt{ native } & Native haskell format \\ \texttt{ markdown } & Markdown syntax \\ \texttt{ man } & Unix groff man page \\ \texttt{ rst } & Restructured text \\ \texttt{ html } & Html \\ \texttt{ \LaTeX{} } & \LaTeX{} typesetting format \\ \texttt{ docbook } & The docbook xml format \\ \texttt{ opendocument } & An xml document format a bit like docbook \\ \texttt{ mediawiki } & The markup used with 'wikipedia' \\ \texttt{ odt } & The open office document format \\ \texttt{ s5 } & An html and javascript slide show format (like powerpoint) \\ \texttt{ rtf } & Rich text format for word processors (eg ms word) \\ \hline \end{tabular} \end{center} Some of the output formats are documented in the user guide but not in the man page. \emph{ Convert a markdown document 'doc.txt' to xml docbook format saved in 'out.xml' } \begin{lstlisting} pandoc -t docbook -o out.xml doc.txt \end{lstlisting} \begin{lstlisting} pandoc --to docbook -o out.xml doc.txt ~(the same) \end{lstlisting} \begin{lstlisting} pandoc -w docbook -o out.xml doc.txt ~(the same again) \end{lstlisting} \begin{lstlisting} pandoc --write docbook -o out.xml doc.txt \end{lstlisting} \emph{ DocBook XML: } \begin{lstlisting} pandoc -s -S -w docbook README -o example9.db \end{lstlisting} \emph{ Convert 'pandoc.1.md' in markdown format to a unix man page 'eg10.1' } \begin{lstlisting} pandoc -s -w man pandoc.1.md -o eg10.1 \end{lstlisting} \emph{ Convert a 'markdown' text document to tex format with pandoc } \begin{lstlisting} pandoc -o out.tex doc.txt \end{lstlisting} \emph{ Convert From LaTeX to markdown: } \begin{lstlisting} pandoc -s example4.tex -o example5.text \end{lstlisting} \emph{ Convert a 'markdown' text file to a stand-alone \LaTeX{} file } \begin{lstlisting} pandoc -s -o out.tex doc.txt \end{lstlisting} \emph{ Convert the file 'doc.txt' in markdown format to an html webpage 'doc.html' } \begin{lstlisting} pandoc doc.txt \end{lstlisting} \emph{ Convert an input stream into the \LaTeX{} format saved as 'out.tex' } \begin{lstlisting} cat doc.txt | pandoc -o out.tex \end{lstlisting} \subsection{Creating Pdf Files} Pandoc uses 'pdflatex' to create pdf files from the source text document. \emph{ Convert the file 'doc.txt' in markdown syntax to a printable pdf 'doc.pdf' } \begin{lstlisting} markdown2pdf doc.txt \end{lstlisting} \emph{ Convert 'doc.txt' written in markdown format to the pdf file 'output.pdf' } \begin{lstlisting} markdown2pdf -o output.pdf doc.txt \end{lstlisting} \emph{ Convert 'doc.txt' to a pdf file 'doc.pdf' which has a table of contents } \begin{lstlisting} markdown2pdf --toc doc.txt \end{lstlisting} \emph{ Create a pdf file from 'doc.txt' with a table of contents and numbered sections } \begin{lstlisting} markdown2pdf -N --toc doc.txt \end{lstlisting} \emph{ Create a pdf document called 'stdin.pdf' from the markdown document 'doc.txt' } \begin{lstlisting} cat doc.txt | markdown2pdf \end{lstlisting} \emph{ Specify that the input format is html } \begin{lstlisting} pandoc -f html doc.txt \end{lstlisting} \emph{ Convert the file 'input.txt' to pdf format on a non-utf8 system } \begin{lstlisting} iconv -t utf-8 input.txt | pandoc | iconv -f utf-8 \end{lstlisting} \begin{lstlisting} iconv -t utf-8 input.txt | markdown2pdf | iconv -f utf-8 ~(better ??) \end{lstlisting} \emph{ PDF with numbered sections and a custom LaTeX header, compilable with 'xetex' } \begin{lstlisting} markdown2pdf -N --template=mytemplate.tex --variable version=1.4 README --xetex --toc -o example \end{lstlisting} (xetex may be good for international character sets) \subsection{Converting To Texinfo} Texinfo is the format of the free software foundation, also known as gnu. Its not a pleasant format \emph{ Convert markdown to a texinfo file } \begin{lstlisting} pandoc README -s -o example19.texi \end{lstlisting} \emph{ Convert the texinfo source into 'info', html and pdf } \begin{lstlisting} makeinfo example19.texi -o example19.info makeinfo example19.texi --html -o example19 texi2pdf example19.texi # produces example19.pdf \end{lstlisting} \subsection{Converting To Html} \emph{ Convert the text file 'doc.txt' to html linking to css style sheet 'sty.css' } \begin{lstlisting} pandoc -c sty.css doc.txt ~(doc.txt uses markdown syntax) \end{lstlisting} \emph{ Display a markdown text document to an html page and send to standard output } \begin{lstlisting} pandoc -s -o - doc.txt \end{lstlisting} \emph{ HTML with smart quotes, table of contents, CSS, and custom footer: } \begin{lstlisting} pandoc -s -S --toc -c pandoc.css -A footer.html README -o example3.html \end{lstlisting} \subsection{Convert From Html} \emph{ Convert a webpage to the markdown format and save as 'eg.txt' } \begin{lstlisting} html2markdown http://www.gnu.org/software/make/ -o eg.text \end{lstlisting} \section{Halibut} \begin{description}[labelindent=1cm, leftmargin=2cm, style=nextline] \item[\url{http://www.chiark.greenend.org.uk/~sgtatham/halibut/}] \end{description} Halibut is a system for creating formatted documents in a variety of output formats such as html (web-pages) pdf (printable) ... Halibut, uses a terse plain text input format. Halibut does not fully support unicode. Halibut may fill a gap between 'enscript' and '\LaTeX{}' or 'docbook' in that the user may quickly produce a typeset document with 'formatting'. An alternative may be to write a new 'style' for enscript. Halibut produces nice pdf output, with automatic table of contents and cross-references. It is essentially a 'poor-mans' (and terse) \LaTeX{} \emph{ Enscript seems to support the halibut format. } \arrayrulecolor{gray} \begin{center} \begin{tabular}{ |rl| } \multicolumn{2}{c}{\textbf{ halibut output formats }} \\ \hline \texttt{ Plain ASCII text } & \\ \texttt{ HTML } & \\ \texttt{ Unix man page format } & \\ \texttt{ GNU info format } & \\ \texttt{ PDF } & \\ \texttt{ PostScript } & \\ \texttt{ Old-style Windows Help (.HLP); } \\ \hline \end{tabular} \end{center} \arrayrulecolor{gray} \begin{center} \begin{tabular}{ |rl| } \multicolumn{2}{c}{\textbf{ halibut markup codes (text is placed between the braces) }} \\ \hline \texttt{ \textbackslash e$\{$$\}$ } & Emphasize (eg italicize) the text between the braces \\ \texttt{ \textbackslash c$\{$$\}$ } & Format as code (normally use a fixed-pitch font such as courier) \\ \texttt{ \textbackslash cw$\{$$\}$ } & Format as weak code \\ \texttt{ \textbackslash cq$\{$$\}$ } & Format as quoted code \\ \texttt{ \textbackslash k$\{$$\}$ \textbackslash K$\{$$\}$ } & A reference to document section heading \\ \texttt{ \textbackslash W$\{$http://www.google.com/$\}$$\{$Google$\}$ } & Url markup \\ \texttt{ \textbackslash i$\{$words$\}$ } & Index the words within the braces \\ \texttt{ \textbackslash u00F6$\{$oe$\}$ } & Embedd a unicode character in the text \\ \texttt{ \textbackslash q$\{$$\}$ } & Quoted text \\ \texttt{ \textbackslash quote$\{$$\}$ } & A long, maybe multi-paragraph quotations \\ \texttt{ \textbackslash rule } & A horizontal rule on the page (should go on a line by itself) \\ \texttt{ \textbackslash C \textbackslash H \textbackslash S \textbackslash A \textbackslash U } & Chapter and section headings \\ \texttt{ \textbackslash title } \\ \hline \end{tabular} \end{center} \subsection{Gotchas} \emph{ You cant have headings without chapters, etc (its not like html) } \emph{ Chapters start new pages and there doesnt seem to be any way around this } \emph{ Very few formatting codes in halibut, eg no 'bold' text, or font size } \emph{ I dont think that you can put images in the document } \subsection{Formatting Examples} \emph{ Display text between quotes } \begin{lstlisting} here is some \q{text in quotes} \end{lstlisting} \emph{ Format code with some un-line-breakable hyphens and underscores } \begin{lstlisting} the Emacs command \c{M\-x\_psychoanalyze\-pinhead} \end{lstlisting} \emph{ Halibut codes can be multi-line } \begin{lstlisting} \e{this is emphasised} \end{lstlisting} \emph{ Include an automatically generated date } \begin{lstlisting} This document was generated on \date \end{lstlisting} (the date looks like 'Thu Feb 1 12:20:43 2007') \emph{ Include an auto-date in a specific format } \begin{lstlisting} This document was generated on \date{%Y-%m-%d %H:%M:%S} \end{lstlisting} (this date looks like '2007-02-01 12:20:43') \emph{ View possible date format strings } \begin{lstlisting} man ? strftime \end{lstlisting} \subsection{Urls} \emph{ Format a url with the display string 'google' } \begin{lstlisting} Try searching on \W{http://www.google.com/}{Google}. \end{lstlisting} \emph{ Display a url with itself as the display string } \begin{lstlisting} Google is at \W{http://www.google.com/}\cw{www.google.com} \end{lstlisting} \emph{ For pdf output use code formatting for urls, if no link is required } \begin{lstlisting} Try searching on \c{http://www.google.com/} \end{lstlisting} \begin{lstlisting} Try searching on \cw{http://www.google.com/} ~(nearly the same) \end{lstlisting} \subsection{Unicode} \emph{ Include a unicode character in the document } \begin{lstlisting} \u0041 ~(this would display 'A' since 41 is the code for 'A') \end{lstlisting} \emph{ Include the 'euro' symbol or the text 'EUR\_' if the symbol is not available } \begin{lstlisting} This is likely to cost \u20AC{EUR\_}2500 at least. \end{lstlisting} \emph{ Include a comment in a document, which will be ommited in the output } \begin{lstlisting} The typical behaviour of an antelope \#{do I mean gazelle?} is.. \end{lstlisting} \emph{ Include code in a halibut source document } \begin{lstlisting} \c #include \c \c int main(int argc, char **argv) { \c printf("hello, world\n"); \c return 0; \c } \end{lstlisting} \subsection{Chapter And Section Headings} \emph{ Create a title for the whole document } \begin{lstlisting} \title A Simple Car Manual \end{lstlisting} \emph{ Create a chapter heading 'special tools' with a reference keyword 'tools' } \begin{lstlisting} \C{tools} Special Tools \end{lstlisting} \emph{ Insert a cross-reference to the tools chapter created above } \begin{lstlisting} see the \k{tools} chapter \end{lstlisting} \emph{ Create a heading (one level below chapters) } \begin{lstlisting} \H{tool-types} Tool Types \end{lstlisting} \emph{ Create a section heading (two levels below a chapter) } \begin{lstlisting} \s{sec1} other concerns \end{lstlisting} \emph{ Create a section which is called a 'question' in the table of contents } \begin{lstlisting} \S{question-about-fish}{Question} What about fish? \end{lstlisting} \emph{ Create an appendix } \begin{lstlisting} \A \end{lstlisting} \subsection{Lists} \emph{ Include a list in a document } \begin{lstlisting} A list follows, \b One. \b Two. \b Three. \end{lstlisting} \emph{ Format a numbered list } \begin{lstlisting} A list follows, \n One. \n Two. \n Three. \end{lstlisting} \emph{ Format a list with a reference } \begin{lstlisting} \n One. \n{this-one} Two. \n Three. \n go back to step \k{this-one}. \end{lstlisting} \emph{ Create a description list } \begin{lstlisting} \dt Pelican \dd This is a large bird with a big beak. \dt Panda \dd This isn't. \end{lstlisting} \emph{ Create a horizontal rule } \begin{lstlisting} \rule \end{lstlisting} \subsection{Cross References} \emph{ Include references or links to document sections } \begin{lstlisting} \K{chap1} expands on \k{chap2}. ~('chap1' and 'chap2' are keywords) \end{lstlisting} (\textbackslash K starts with a capital letter) \emph{ Define a bibliography entry } \begin{lstlisting} \B{freds-book} \q{The Taming Of The Mongoose}, by Fred Bloggs. \end{lstlisting} \begin{lstlisting} Published by Paperjam & Notoner, 1993. \end{lstlisting} \emph{ Refer to a bibliography entry with the \textbackslash k command } \begin{lstlisting} \k{freds-book} \end{lstlisting} \emph{ Create a citation to a book } \begin{lstlisting} \nocite{abook} \end{lstlisting} \subsection{The Index} \emph{ Create an index entry in a source document } \begin{lstlisting} The \i{hippopotamus} is a particularly large animal. \end{lstlisting} (the index will include the word 'hippo' and the page where is occurs) \emph{ Create a multi-word index entry } \begin{lstlisting} we recommend a \i{torque wrench} for this job. \end{lstlisting} \emph{ Create an index entry for a code term } \begin{lstlisting} \i\c{grep} command is what you want here. \end{lstlisting} \emph{ Create an index for a word and emphasise it in the text } \begin{lstlisting} this is what we call a \i\e{paper jam} \end{lstlisting} \emph{ Create an index entry which doesnt appear in the text } \begin{lstlisting} If your printer runs out of toner, \I{replacing toner cartridge} do this: \end{lstlisting} \subsection{Configuring Halibut} For producing pdf or postscript documents, all the margins and other spacings are configurable, using the \textbackslash cfg command. \begin{description}[labelindent=1cm, leftmargin=2cm, style=nextline] \item[\url{http://www.chiark.greenend.org.uk/~sgtatham/halibut/doc-1.0/output.html\#output-paper}] options to configure pdf output \end{description} \emph{ Configure something } \begin{lstlisting} \cfg \end{lstlisting} \emph{ Label all chapters as 'Book' } \begin{lstlisting} \cfg{chapter}{Book} \end{lstlisting} \emph{ Define a macro } \begin{lstlisting} \define{eur} \u20AC{EUR\_} \end{lstlisting} \emph{ Use the macro which was just defined } \begin{lstlisting} This is likely to cost \eur 2500 at least. \end{lstlisting} \emph{ Configure the font size of the document text } \begin{lstlisting} \cfg{paper-base-font-size}{points} Specifies the font size of body text. \end{lstlisting} \emph{ Other config options } \begin{lstlisting} \cfg{paper-page-height}{points} Specify the absolute limits of the paper. \cfg{paper-left-margin}{points} \cfg{paper-top-margin}{points} \cfg{paper-right-margin}{points} \cfg{paper-bottom-margin}{points} Specify the margin \end{lstlisting} \subsection{Compiling Documents} \emph{ Produce html 'test.html' from the input text file 'file.txt' } \begin{lstlisting} halibut --html=test.html file.txt \end{lstlisting} \emph{ Create a pdf file 'output.pdf' from the input file 'file.txt' } \begin{lstlisting} halibut --pdf file.txt \end{lstlisting} \section{Enscript} enscript is the simplest solution for creating a printed document, and such a handy way to quickly get some printed output without wasting precious paper. its great. Enscript may be able to produce postscript and pdf output quickly but it also has many options, which may make more complex typesetting tools unnecessary. \emph{ View a postscript file } \begin{lstlisting} gv file.ps \end{lstlisting} \begin{lstlisting} evince file.ps ~(nicer than the ancient 'gv') \end{lstlisting} \subsection{Basic Usage} The output file, if it exists, is overwritten. \emph{ Convert plain text 'file.txt' to a pdf file 'output.pdf' } \begin{lstlisting} enscript -p file.ps file.txt; ps2pdf file.ps \end{lstlisting} \emph{ Create a pdf file from 'file.txt' } \begin{lstlisting} enscript -o - file.txt | ps2pdf - file.pdf \end{lstlisting} \emph{ Create a postscript document from the '.txt' files in the current folder } \begin{lstlisting} enscript -p output.ps *.txt \end{lstlisting} \emph{ Create a postscript document from 2 files, each line containing 'honey' } \begin{lstlisting} cat file1.txt file2.txt | grep -v honey | enscript -p output.ps \end{lstlisting} (using this method enscript cant put the filename in the header) \subsection{Headers And Footers} The header is what is printed at the top of each page of the outputted postscript document. \arrayrulecolor{gray} \begin{center} \begin{tabular}{ |rl| } \multicolumn{2}{c}{\textbf{ special enscript header/footer codes }} \\ \hline \texttt{ \$\$ } & Character '\$' \\ \texttt{ \$\% } & Current page number \\ \texttt{ \$= } & Number of pages in the current file \\ \texttt{ \$p } & Number of pages processed so far \\ \texttt{ \$(VAR) } & Value of the environment variable VAR. \\ \texttt{ \%c } & Trailing component of the current working directory \\ \texttt{ \%C } & (\$C) current time (file modification time) in 'hh:mm:ss' format \\ \texttt{ \%d } & Current working directory \\ \texttt{ \%D } & (\$D) current date (file modification date) in 'yy-mm-dd' format \\ \texttt{ \%D$\{$string$\}$ } & (\$D$\{$string$\}$) '\%D$\{$$\}$' refers to the current date and `\$D$\{$$\}$' to the input file's last modification date. \\ \texttt{ \%E } & (\$E) current date (file modification date) in 'yy/mm/dd' format \\ \texttt{ \%F } & (\$F) current date (file modification date) in 'dd.mm.yyyy' \\ \texttt{ \%H } & Document title \\ \texttt{ \$L } & Number of lines in the current input file. This is valid strings. \\ \texttt{ \%m } & The hostname up to the first '.' character \\ \texttt{ \%M } & The full hostname \\ \texttt{ \%n } & The user login name \\ \texttt{ \$n } & Input file name without the directory part \\ \texttt{ \%N } & The user's pw\_gecos field up to the first ',' character \\ \texttt{ \$N } & The full input file name \\ \texttt{ \%t } & Current time in 12-hour am/pm \\ \texttt{ \$t } & File modification time in 12-hour am/pm \\ \texttt{ \%T } & Current time in 24-hour format \\ \texttt{ \$T } & File modification time in 24-hour format \\ \texttt{ \%* } & (\$*) current time (file modification time) in 24-hour format \\ \texttt{ \$v } & The sequence number of the current input file \\ \texttt{ \%W } & (\$W) current date (file modification date) in 'mm/dd/yy' format \\ \hline \end{tabular} \end{center} \emph{ Create a pdf file with no ``headers'' called ``output.pdf'' } \begin{lstlisting} enscript -B -p output.ps file.txt; pd2pdf output.ps \end{lstlisting} \begin{lstlisting} enscript -Bp output.ps file.txt; pd2pdf output.ps ~(the same) \end{lstlisting} \begin{lstlisting} enscript -Bo - file.txt | pd2pdf - output.ps ~(the same) \end{lstlisting} \emph{ Create a document with the text 'A summers day' at the top of each page } \begin{lstlisting} enscript -b 'The summers day' -p out.ps file.txt \end{lstlisting} \begin{lstlisting} enscript --header='The summers day' -p out.ps file.txt ~(the same) \end{lstlisting} \emph{ Output a document with header as filename, current date, and page numbers } \begin{lstlisting} enscript --header='$n %W Page $% of $=' -p out.ps file.txt \end{lstlisting} \begin{lstlisting} enscript -b '$n %W Page $% of $=' -p out.ps file.txt \end{lstlisting} (this would print 'out.ps 12/12/2003 Page 2 of 20' or something like that) \emph{ Create a document with a header with 'justified' fields (left, center, right) } \begin{lstlisting} enscript --header='$n|%W|Page $% of $=' -p out.ps file \end{lstlisting} \emph{ Create a postscript file 'output.ps' with fancy grey headers } \begin{lstlisting} enscript -G -p output.ps list.txt \end{lstlisting} (the header contains the date, file name and the page number) \emph{ Create a ps document with a footer which is like 'Page 2 of 24' } \begin{lstlisting} enscript --footer='Page $% of $=' -p out.ps file.txt \end{lstlisting} \subsection{Changing The Font} The text after the '-f' switch has to be a valid font specification, \emph{ Show all valid font names which can be used with the enscript -f option } \begin{lstlisting} less /usr/share/enscript/afm/font.map ~(your mileage may vary) \end{lstlisting} \begin{lstlisting} find / -name 'font.map' ~(if the above didnt work) \end{lstlisting} \emph{ Create a postscript file ``new.ps'' using the font ``Helvetica12'' } \begin{lstlisting} enscript -f "Helvetica12" -p new.ps file.txt \end{lstlisting} \begin{lstlisting} enscript -f "Helvetica@12" -p new.ps file.txt ~(the same) \end{lstlisting} \begin{lstlisting} enscript -fHelvetica12 -p new.ps file.txt ~(this seems to work as well) \end{lstlisting} \emph{ These font names are case sensitive!! } \begin{lstlisting} enscript -f "helvetica12" -p new.ps file.txt \end{lstlisting} \emph{ Create a postscript document using 8.5 point Times-Roman font } \begin{lstlisting} enscript -f 'Times-Roman8.5' -p new.ps file.txt \end{lstlisting} \begin{lstlisting} enscript -f 'Times-Roman@8.5' -p new.ps file.txt ~(should be the same) \end{lstlisting} \emph{ Create a document using a font which is 10 points wide and 14 points high } \begin{lstlisting} enscript -f 'Courier@10/14' -p new.ps file.txt \end{lstlisting} \emph{ Create a postscript file with a smaller font } \begin{lstlisting} enscript -f "Helvetica8" -p new.ps file.txt \end{lstlisting} \begin{lstlisting} enscript -f "Helvetica6" -p new.ps file.txt ~(only 6 points!) \end{lstlisting} \begin{lstlisting} enscript -f "Helvetica4" -p new.ps file.txt ~(tiny, need a good printer) \end{lstlisting} \subsection{Creating Banner Text With Enscript} \begin{description}[labelindent=1cm, leftmargin=2cm, style=nextline] \item[\url{http://www.linux.com/archive/articles/55835}] how to make 'web banners' (an image to go at the top of a webpage) using enscript, by Michael Stutz, the same guy who wrote the Linux Cookbook for No Starch Press. \end{description} \emph{ Make a large image of the text 'Green Tree' } \begin{lstlisting} echo "Green Tree" | enscript -B -f "Palatino-Bold48" -o blog.ps \end{lstlisting} \begin{lstlisting} echo "Green Tree" | enscript -Bf "Palatino-Bold48" -p blog.ps ~(same) \end{lstlisting} \emph{ Do the whole thing in imagemagick } \begin{lstlisting} convert -font Helvetica-Bold -pointsize 48 -background black -fill red label:'Hallo world' allo.png \end{lstlisting} \emph{ Crop out all the unnecessary space around the text and convert to 'jpg' } \begin{lstlisting} convert -crop WxH+0+0 filename.ps filename.jpg ~(width and height) \end{lstlisting} \begin{lstlisting} convert -trim +repage filename.ps filename.jpg ~(untested) \end{lstlisting} \emph{ All in one go } \begin{lstlisting} echo "Headlines for `date +'%B %e'`" | enscript -o - -B -f "Times-Bold48" | convert -crop 200x600+0+0 - headlines.png ~(untested) \end{lstlisting} \subsection{Multiple Columns} \emph{ Change the horizontal column height } \begin{lstlisting} --h-column-height=height \end{lstlisting} \emph{ Make a postscript file (from 2 text files) with 3 columns, and view it. } \begin{lstlisting} cat file1.txt file2.txt | enscript -3p output.ps; evince output.ps \end{lstlisting} \emph{ Create a 2 column postscript file with lines separating columns and a frame } \begin{lstlisting} enscript -2 -j -p file.ps file.txt \end{lstlisting} \begin{lstlisting} enscript -2jp file.ps file.txt ~(the same, but better) \end{lstlisting} \emph{ Create a pdf document with 20 columns and no 'headers' (thats right, 20) } \begin{lstlisting} enscript --columns=20 -2Bp file.ps file.txt; ps2pdf file.ps \end{lstlisting} (the 'header' is the text which appears at the top of each page) \emph{ Create a postscript document 'new.ps' with 9 columns from 'file.txt' } \begin{lstlisting} enscript -9p new.ps file.txt \end{lstlisting} \subsection{Landscape Printing} \emph{ Convert ``file.txt'' to pdf ``file.pdf'' landscape format with 2 columns } \begin{lstlisting} enscript -2r -p file.ps file.txt; ps2pdf file.ps \end{lstlisting} \subsection{Changing The Margins} \emph{ Set the margins in the document to those specified } \begin{lstlisting} enscript --margins=50:50:50:100 -p tree.ps tree.txt \end{lstlisting} \emph{ In my version of enscript 1.6.4 the format for the margin command is } \begin{lstlisting} --margins=top:bottom:right:left which is a very unusual order \end{lstlisting} \emph{ But in the documentation the format is stated to be } \begin{lstlisting} --margins=top:bottom:right:left which would be more logical \end{lstlisting} \emph{ Set the left and right margins to 50 pnts with top and bottom default } \begin{lstlisting} enscript --margins=50:50 -p tree.ps tree.txt \end{lstlisting} \emph{ Indent every line by 2 character widths } \begin{lstlisting} enscript -i 2l ~(2 character widths) \end{lstlisting} \begin{lstlisting} enscript -i 20p ~(indent by 20 points) \end{lstlisting} \begin{lstlisting} enscript -i 3i ~(3 inches) \end{lstlisting} \begin{lstlisting} enscript -i 3c ~(3 centimetres) \end{lstlisting} \subsection{Underlayed Text} Enscript can print an 'underlayed' text which is like a watermark which goes underneath the text from the file. \emph{ Create a postscript file with a ``watermark'' large font text diagonally } \emph{ Down the page. } \begin{lstlisting} enscript -u"Resume" -p file.ps file.txt \end{lstlisting} \subsection{Output Formats} Instead of creating postscript files, enscript can also create 'rtf' (rich text format) files (which can be opened in Microsoft Word, for example) and 'html' files, which can be viewed with a web-browser such as 'google chrome', 'firefox' or 'internet explorer'. \emph{ Create a rich text file 'output.rtf' from a text file with no headers } \begin{lstlisting} enscript -wrtf -B -p output.rtf file.txt \end{lstlisting} (rtf files can be opened in wysiwyg editors like MS Word) \emph{ Create a colourised webpage of the file ``tree.txt'' } \begin{lstlisting} enscript -whtml --color -E -p file.html tree.txt \end{lstlisting} \subsection{Changing The Printout} \emph{ Make a pdf file 'output.pdf' with each line preceded by the line number } \begin{lstlisting} enscript --line-numbers -p output.ps list.txt; ps2pdf output.ps \end{lstlisting} \begin{lstlisting} enscript -Cp output.ps list.txt; ps2pdf output.ps ~(the same) \end{lstlisting} \emph{ Create a document with each line numbered starting at line 20 } \begin{lstlisting} enscript -C20 -p output.ps list.txt \end{lstlisting} \subsection{The Page Size} \emph{ Show what page sizes enscript can output to } \begin{lstlisting} enscript --list-media \end{lstlisting} \emph{ Create a postscript document with an 'A5' page size } \begin{lstlisting} enscript -M A5 -p out.ps file.txt \end{lstlisting} \begin{lstlisting} enscript --media=A5 -p out.ps file.txt ~(the same) \end{lstlisting} \subsection{Making Booklets} By using the 'N-up' printing facilities of enscript it should be possible to create 'booklets', that is, postscript documents which when printed out and folded in half, have all the pages in the right place (just like a real book; this is also called 'quires'). N-up printing involves putting a multiple of 2 logical pages on each physical page. \emph{ Put 2 logical pages on each physical page } \begin{lstlisting} enscript -U2 -p out.ps file.txt \end{lstlisting} \begin{lstlisting} enscript -nup=2 -p out.ps file.txt ~(the same) \end{lstlisting} \emph{ Put 4 logical pages on each page } \begin{lstlisting} enscript -U4 -p out.ps file.txt \end{lstlisting} \emph{ Other nup options which may do what we need } \begin{lstlisting} --nup-columnwise Change the layout of the sub-pages in the N-up printing from row- wise to columnwise. --nup-xpad=num Set the page x-padding of the n-up printing to num PostScript points. The default is 10 points. --nup-ypad=num Set the page y-padding of the n-up printing to num PostScript points. The default is 10 points. \end{lstlisting} \subsection{Printing Code} Enscript can be used to provide nice listing of software 'code'. \emph{ Show what code languages enscript can pretty-print } \begin{lstlisting} enscript --help-highlight | grep 'Name:' | less \end{lstlisting} \begin{lstlisting} enscript --help-highlight | less ~(show more detailed information) \end{lstlisting} \emph{ Create a colourised webpage of the file ``Point.java'' with syntax highlighting } \begin{lstlisting} enscript -whtml --color -E -p file.html Point.java \end{lstlisting} \emph{ Print a gaudy header, two columns, landscape, code highlighting, 2-up printing. } \begin{lstlisting} enscript -G2rE -U2 foo.c \end{lstlisting} \emph{ When a line is too long and must be wrapped print an arrow at the line end } \begin{lstlisting} enscript --mark-wrapped-lines=arrow -p output.ps list.txt \end{lstlisting} \begin{lstlisting} --mark-wrapped-lines={plus|box|arrow} \end{lstlisting} \section{Other Plain Text Documentation Systems} This book tries to elucidate the forest of different ways and formats in which to write text documentation and the software which is used to transform the text into other digital formats and printed documents. commandlinefu.com \section{Man Pages} man: software $<$man$>$ual pages Man ('manual') pages is the traditional Unix documentation format. The man page format is a simple plain text format using macros for the troff or groff document system. The Man documentation system is specifically designed for documenting software. \begin{description}[labelindent=1cm, leftmargin=2cm, style=nextline] \item[\url{http://www.schweikhardt.net/man_page_howto.html}] links to documents by Kernighan ... \item[\url{http://babbage.cs.qc.edu/courses/cs701/Handouts/man_pages.html}] \end{description} \subsection{Viewing Man Pages} \emph{ Viewing a man page with 'man' (the normal way to view a man page) } \begin{lstlisting} man program ~(the file program.n must be in the manpath) \end{lstlisting} \emph{ Viewing the bobble manpage with groff (useful when writing a man page) } \begin{lstlisting} groff -man -Tascii bobble.1 | less \end{lstlisting} \begin{lstlisting} groff -man -Tutf8 bobble.1 | less \end{lstlisting} \emph{ Viewing the 'bobble' program man page with nroff } \begin{lstlisting} nroff -man bobble.1 | less \end{lstlisting} \emph{ View the raw groff text for the 'bobble' program man page. } \begin{lstlisting} zless .../man/man1/bobble.1.gz ~(if the pages are compressed) \end{lstlisting} \begin{lstlisting} less .../man/man1/bobble.1 ~(if the pages are not compressed) \end{lstlisting} (useful to learn how to write a man page.) (type 'manpath' to find the path to the manpages) \emph{ Other viewing tools are xman, tkman, info } \subsection{Writing Man Pages} \emph{ See the conventions for writing a man page } \begin{lstlisting} man 7 man \end{lstlisting} \emph{ See the formatting codes available } \begin{lstlisting} man groff_man \end{lstlisting} \begin{itemize} \item \item decide what section the page should go in (see:man page sections) \item write the man page \item name the file 'name.n' where 'n' is the section \item place the file in .../man/manN/ where 'N' is the section (same as above) \item if the page is not written in english, place the file in the folder .../man/aa/manN/ where 'aa' is a language or locale code, for example 'fr' for french, or 'es' for spanish. and 'N' is the section. \item \end{itemize} \subsection{Man Formatting Conventions} While the author of a unix man page is free to format the document as she feels fit, certain conventions are time-tested and true. \emph{ In the synopsis section use bold alternating with italic for functions } \begin{lstlisting} .BI "myfunction(int " argc ", char **" argv ); \end{lstlisting} \emph{ File names in italic outside of the 'synopsis' section } \begin{lstlisting} .I /usr/include/stdio.h \end{lstlisting} \emph{ In the synopsis section, make file names bold } \begin{lstlisting} .B #include \end{lstlisting} \emph{ Put references to other man pages in bold alternating with roman } \begin{lstlisting} .BR man (7) \end{lstlisting} \emph{ Format acronymns in a small font } \begin{lstlisting} .SM UNIX \end{lstlisting} \emph{ Summarize command options with .IP } \begin{lstlisting} .IP -b \end{lstlisting} \subsection{Man Formatting Codes} \emph{ View the man macro help for a list of formatting codes } \begin{lstlisting} man groff_man ~(as usual, this contains no examples) \end{lstlisting} \emph{ Create a document title } \begin{lstlisting} .TH FOO 1 "MARCH 2003" Linux "User Manuals" \end{lstlisting} (command name: foo, section: 1 (user commands) ) (last revision: march 2003, other title: Linux ...) \emph{ Section heading } \begin{lstlisting} .SH heading \end{lstlisting} \emph{ Subsection headings } \begin{lstlisting} .SS heading \end{lstlisting} \emph{ Display a sentence in italics } \begin{lstlisting} .I "some words" \end{lstlisting} \emph{ Put the word 'type' in italics } \begin{lstlisting} /fItype/fP ~(groff codes) \end{lstlisting} \emph{ Insert preformatted text in a man page (using groff requests) } \begin{lstlisting} .nf pre formatted text ... .fi \end{lstlisting} \emph{ Begin a new paragraph } \begin{lstlisting} .PP \end{lstlisting} \emph{ Indent an option list with .TP (the first line after .TP is the label) } \begin{lstlisting} > \end{lstlisting} .TP \textbackslash -h display a short help text .TP \textbackslash -d use the given device $<$$<$$<$ (.TP has the advantage over .IP that the paragraph label can be formatted) \emph{ Hanging left indented paragraph } \begin{lstlisting} .HP \end{lstlisting} \emph{ Indented paragraph with label } \begin{lstlisting} .IP label \end{lstlisting} this can be used for summarizing options etc. If the label is long then the indented paragraph is begun on a new line (definition list style) other wise the indented paragraph is begun on the same line. (table style) example: .IP -b turn on debug mode .IP ``-config file'' load the specifed config file --; \emph{ Indent the following text by the default amount } \begin{lstlisting} .RS \end{lstlisting} \emph{ Indent the following text by 10 } \begin{lstlisting} .RS 10 \end{lstlisting} \emph{ Stop indenting text } \begin{lstlisting} .RE stop indenting \end{lstlisting} \subsection{Standard Man Page Document Sections} \emph{ A comment with the groff command } \begin{lstlisting} > \end{lstlisting} .\textbackslash " Process this file with .\textbackslash " groff -man -Tascii foo.1 .\textbackslash " $<$$<$$<$ \emph{ The title of the document } \begin{lstlisting} .TH FOO 1 "MARCH 1995" Linux "User Manuals" \end{lstlisting} \emph{ Name, the name of the command etc } \begin{lstlisting} > \end{lstlisting} .SH NAME boggle \textbackslash - frobnicate the bar library $<$$<$$<$ \emph{ Synopsis, summary of the command usage } \begin{lstlisting} > \end{lstlisting} .SH SYNOPSIS .B boggle [-bar] [-c .I config-file .B ] .I file .B ... $<$$<$$<$ \emph{ Description, a complete description of what the command does } \begin{lstlisting} .SH DESCRIPTION .B boggle frobnicates the bar library by tweaking internal symbol tables. By default it parses all baz segments and rearranges them in reverse order by time for the .BR xyzzy (1) linker to find them. The symdef entry is then compressed using the WBG (Whiz-Bang-Gizmo) algorithm. All files are processed in the order specified. \end{lstlisting} \emph{ Options, the options which the command accepts } \begin{lstlisting} .\" this could be formatted with a .TP list as well .SH OPTIONS .IP -b Do not write `busy' to stdout while processing. .IP "-c config-file" Use the alternate system wide .I config-file instead of .IR /etc/foo.conf . \end{lstlisting} \emph{ Files, other files which the command uses (a .TP list could be used) } \begin{lstlisting} > \end{lstlisting} .I /etc/foo.conf .RS The system wide configuration file. See .BR foo (5) .RE .I $\sim$/.foorc .RS Per user configuration file. $<$$<$$<$ \emph{ Environment, any environment variables which affect the program } \begin{lstlisting} > \end{lstlisting} .IP FOOCONF If non-null the full pathname for an alternate system wide .IR foo.conf . Overridden by the .B -c option. $<$$<$$<$ \emph{ Diagnostics, messages which the program may display } \begin{lstlisting} .SH DIAGNOSTICS The following diagnostics may be issued on stderr: Bad magic number. .RS The input file does not look like an archive file. .RE Old style baz segments. .RS .B foo can only handle new style baz segments. COBOL object libraries are not supported in this version. \end{lstlisting} \emph{ Bugs, problems with the program } \begin{lstlisting} .SH BUGS The command name should have been chosen more carefully to reflect its purpose. \end{lstlisting} \emph{ Author } \begin{lstlisting} > \end{lstlisting} .SH AUTHOR bob good $<$who at server dot net$>$ $<$$<$$<$ \emph{ See also, other programs or documents relevant to this one. } \begin{lstlisting} > \end{lstlisting} .SH ``SEE ALSO'' .BR bar (1), .BR boggle (5), $<$$<$$<$ \subsection{Standard Location Of Man Pages} Man pages should be placed in their appropriate section (subfolder) and with the correct extension \begin{description}[labelindent=1cm, leftmargin=2cm, style=nextline] \item[\url{http://www.schweikhardt.net/man_page_howto.html}] a man page howto with links to all the manuals \end{description} \emph{ See where the 'man' command searches for man pages } \begin{lstlisting} manpath \end{lstlisting} \emph{ File name and location of the user command 'boggle' man page } \begin{lstlisting} .../man/man1/boggle.1 \end{lstlisting} \begin{lstlisting} .../man/man1/boggle.1.gz ~(man pages can be compressed as well) \end{lstlisting} (the file boggle.1 is a plain text file) \emph{ File name and location of the man page for the library function 'doogle' } \begin{lstlisting} .../man/man3/doogle.3 \end{lstlisting} \emph{ Location of the man page written in french for the library function 'doogle' } \begin{lstlisting} .../man/fr/man3/doogle.3 \end{lstlisting} \emph{ Search for man pages in 'folder' instead of in 'manpath' } \begin{lstlisting} man -M folder boggle \end{lstlisting} (useful while writing and testing man pages) \arrayrulecolor{gray} \begin{center} \begin{tabular}{ |rl| } \multicolumn{2}{c}{\textbf{ manual page sections }} \\ \hline \texttt{ 1 } & User commands executable from a shell \\ \texttt{ 2 } & Kernel system calls \\ \texttt{ 3 } & Library functions and calls (such as libc) \\ \texttt{ 4 } & Special files such as in /dev \\ \texttt{ 5 } & File formats and conventions (such as /etc/password) \\ \texttt{ 6 } & Games \\ \texttt{ 7 } & Conventions and miscellaneous, file system layout. \\ \texttt{ 8 } & System management commands such as like mount(8) \\ \texttt{ 9 } & Kernel routines. this is an obsolete manual section. \\ \hline \end{tabular} \end{center} \emph{ Automatically generate man pages from C, C++, Java, Python ... source code } \begin{lstlisting} doxygen ~(doxygen can also generate documentation in html, latex etc) \end{lstlisting} \emph{ A cgi script for generating html man pages } \begin{lstlisting} man2html \end{lstlisting} \subsection{Converting Man Pages To Other Formats} \emph{ Convert the 'doogle.1' man page to html } \begin{lstlisting} man2html doogle.1 \end{lstlisting} \emph{ Convert to html using groff } \begin{lstlisting} groff -Thtml /path/to/manpage.n \end{lstlisting} \emph{ Rman can convert to \LaTeX{}, rtf, sgml, html, ... } \begin{lstlisting} rman \end{lstlisting} \emph{ Convert the 'ls' manpage to plain text, converting tabs to spaces (-x) } \begin{lstlisting} man ls | col -bx | less \end{lstlisting} \emph{ Convert a man page to postscript } \begin{lstlisting} groff -man -Tps /path/to/manpage.n \end{lstlisting} \emph{ Convert a man page to dvi } \begin{lstlisting} groff -man -Tdvi /path/to/manpage.1 \end{lstlisting} \emph{ Convert a man page to pdf } \begin{lstlisting} man -Tps ls | ps2pdf - ls_man.pdf \end{lstlisting} \subsection{Converting To Man Pages From Other Formats} \emph{ Convert a perl documentation doc (pod) to a man page } \begin{lstlisting} pod2man bogg.pod > bogg.1 \end{lstlisting} \section{Groff And Troff} Troff: $<$T$>$ypesetting $<$R$>$un $<$Off$>$ system Groff: Groff is the Gnu version of the Troff document formatting and typesetting system, which was maintained for many years by Kernighan \begin{description}[labelindent=1cm, leftmargin=2cm, style=nextline] \item[\url{http://www.kohala.com/start/troff/troff.html}] a list of resources and documents for troff \end{description} \subsection{Using Tables} \emph{ Use the tbl macros } \subsection{Diagrams And Pictures With Groff} Creating certain sorts of diagrams with groff can be achieved with the 'pic' preprocessor. http://www.kohala.com/start/troff/cstr116.ps Brian Kernighans manual for pic http://www.kohala.com/start/troff/gpic.raymond.ps A manual for gpic the gnu version of 'pic' \emph{ View the help for the 'pic' diagram generator } \begin{lstlisting} man gpic \end{lstlisting} \emph{ Convert a pic diagram to postscript } \begin{lstlisting} groff -e -p -ms pic.ms > file1.ps \end{lstlisting} \subsection{Mathematical Equations} \emph{ Use the 'eqn' macros } \section{Texinfo} Texinfo is the official documentation system of the Free Software Foundation. \section{Docbook} Docbook is an XML based documentation system \section{Halibut} \begin{description}[labelindent=1cm, leftmargin=2cm, style=nextline] \item[\url{http://www.chiark.greenend.org.uk/~sgtatham/halibut/}] \end{description} \begin{itemize} \item halibut, uses a terse plain text input format \item the output formats for halibut are: (:Plain ASCII text, HTML, Unix man page format, GNU info format, PDF, PostScript, Old-style Windows Help (.HLP); \item not fully unicode \end{itemize} \arrayrulecolor{gray} \begin{center} \begin{tabular}{ |rl| } \multicolumn{2}{c}{\textbf{ halibut input format, (text is placed between the braces) }} \\ \hline \texttt{ \textbackslash e$\{$$\}$ } & Emphasis \\ \texttt{ \textbackslash c$\{$$\}$ } & Code \\ \texttt{ \textbackslash cw$\{$$\}$ } & Weak code \\ \texttt{ \textbackslash cq$\{$$\}$ } & Quoted code \\ \texttt{ \textbackslash W$\{$http://www.google.com/$\}$$\{$Google$\}$ } & Url markup \\ \hline \end{tabular} \end{center} \section{Source Code Documentation Systems} \subsection{Doxygen} \subsection{Javadoc} Javadoc is the document system for the Java programming language. The output format for javadoc is normally HTML \emph{ Pod perl documentation } \end{document}