# Technical documentation and/or book templates?

I'm just getting started with LaTeX and wanted to see some templates for technical documentation and/or books. I'm writing a small book about PHP and wanted to use LaTeX with it, but i wanted to have more control about the appearance (header, footer, "tips" with icons, code samples, table of contents, etc.)

-
Do you have (La)TeX distribution installed on your machine? –  xport Jun 6 '11 at 20:22
This might help: tex.stackexchange.com/q/4420/215 –  Seamus Jun 6 '11 at 21:26
Get either memoir or the KOMA bundle, and start typing away. It is not so hard to fix mistakes later on (even radically switch clases!), and the best way of learning is just trying stuff and reflecting on what works and what doesn't. Look at books not for their contents but for their look and feel. Check out the various galleries (like the MemoirChapStyles gallery of chapter headings or the titlepages gallery) –  vonbrand Jan 17 '13 at 12:23

Your post contains many questions that should be better asked in separate post each. Since you are new to LaTeX and you might want to start writing your book immediately without spending too much time to learn LaTeX in details --- I think you don't need to spend much time to learn how to typeset math, right? --- I guide you how to create the skeleton that will be improved later.

## Step 01

You should start organizing your project from the beginning. Divide your project into at least 3 sub directories, namely MyProject\Contents, MyProject\Images, and MyProject\Codes.

## Step 02

Create your own document class, namely mybook.cls as follows and save it in MyProject directory.

\ProvidesClass{mybook}[2011/06/07 v 0.01 my own class (hv)]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessOptions\relax
[
%other default options go  here
]{book}

\newcommand\ContentsPath{Contents/}
\newcommand\ChapterPath{\ContentsPath}
\newcommand\SectionPath{\ChapterPath}
\newcommand\SubSectionPath{\SectionPath}

{
\newcommand\IncludeChapter[1]
{
\renewcommand\ChapterPath{\ContentsPath#1/}
\include{\ContentsPath#1}
}
\newcommand\IncludeOnlyChapter[1]
{
\includeonly{\ContentsPath#1}
}
}{}

\newcommand\InputSection[1]
{
\renewcommand\SectionPath{\ChapterPath#1/}
\input{\ChapterPath#1}
}

\newcommand\InputSubSection[1]
{
\renewcommand\SubSectionPath{\SectionPath#1/}
\input{\SectionPath#1}
}

\newcommand\InputSubSubSection[1]
{
\input{\SubSectionPath#1}
}

{
\newcommand\Chapter[1]
{
\chapter{#1}
}
}{}

\newcommand\Section[1]
{
\section{#1}%
}

\newcommand\SubSection[1]
{
\subsection{#1}
}

\newcommand\SubSubSection[1]
{
\subsubsection{#1}
}

\RequirePackage{xcolor}

\RequirePackage{listings}
\lstdefinestyle{Common}
{
breaklines=true,
tabsize=3,
showstringspaces=false,
aboveskip=0pt,
belowskip=0pt,
extendedchars=\true,
language=PHP,
frame=single,
%===========================================================
framesep=3pt,%expand outward.
framerule=0.4pt,%expand outward.
xleftmargin=3.4pt,%make the frame fits in the text area.
xrightmargin=3.4pt,%make the frame fits in the text area.
%===========================================================
rulecolor=\color{Red}%
}

\lstdefinestyle{ThemeA}
{
style=Common,
backgroundcolor=\color{Yellow!10},
basicstyle=\scriptsize\color{Black}\ttfamily,
keywordstyle=\color{Orange},
identifierstyle=\color{Cyan},
stringstyle=\color{Red},
}

\newcommand{\IncludeCode}[2][style=ThemeA]
{
\lstinputlisting[#1,caption={\href{#2}{#2}}]{#2}
}

\RequirePackage[all]{hypcap}

\RequirePackage{makeidx}
\makeindex

\endinput


## Step 03

Create the main input file, namely main.tex as follows and save it in MyProject.

\documentclass[dvipsnames,cmyk,12pt]{mybook}
\usepackage[a4paper,vmargin=15mm,hmargin=10mm]{geometry}

\title{Introduction to PHP}
\date{\today}

%\IncludeOnlyChapter{Variables}

\begin{document}
\frontmatter
\maketitle
\thispagestyle{empty}
\tableofcontents
\lstlistoflistings
\mainmatter
\part{Part 1}
\IncludeChapter{Variables}
\IncludeChapter{Array}
\part{Part 2}
\IncludeChapter{Interface}
\IncludeChapter{SubClass}
\appendix\renewcommand{\chaptername}{\appendixname}
\part{Appendix}
\IncludeChapter{YourAppendix}
\backmatter
\printindex
\end{document}


## Step 04

Create a file for chapter Variables, namely Variables.tex, as follows and save it in MyProject\Contents.

\Chapter{Variables}
\InputSection{Declaration}
\InputSection{Instantiation}


## Step 05

Create a directory MyProject\Contents\Variables.

## Step 06

Create a file for section Declaration, namely Declaration.tex, as follows and save it in MyProject\Contents\Variables.

\Section{Declaration}

\IncludeCode[style=ThemeA]{Codes/Declaration.php}


## Step 07

Do the same for the remaining contents.

It is also worth using VCS (versioning control system) such as Subversion or Git to manage your project.

If there is any question, give a comment. :-)

-
Within lists, code blocks have to be indented four additional spaces. –  lockstep Jun 6 '11 at 19:57
@lockstep: Done but with different methods. –  xport Jun 6 '11 at 19:59
I have to agree with using VCS and splitting up the text into separate files for chapters or other divisions. Don't worry, just fling new stuff into the file where it fits. You can reorder all bu shuffling the includes around later. LaTeX is (mostly) free form, indent your source and end lines at logical points (after puctuation, one idea per line, ...). That makes editing easier when you need to restructure a sentence. If you keep your changes line-oriented, your version control system won't show noise (i.e., a whole paragraph change just because you added a word and reflowed the text). –  vonbrand Jan 17 '13 at 12:30

If you are new to LaTex, I'd start gently. Read the standard introductions (such as the not so short introduction). Rather than jumping into producing your own class file immediately, I'd be inclined to start with one of the commonly used classes (probably memoir or scrbook); each of those has good manuals with plenty of customization suggestions for the sort of things you are most likely to want to customize. Frankly, you are probably better picking one and sticking with it (and spending time with the documentation) than agonizing over the choice, since you can customize the appearance of the final product to your taste in due course.

Since you are writing a book about php, you may want some sort of package to deal with listings. I don't have the expertise to make a recommendation on that. But for all sorts of other useful stuff, have a look at this answer on the packages people regularly load.

Definitely learn about the things like \include and \includeonly, todonotes, bibtex (or, probably nowadays, biblatex) which help keep things organised and modular while you are writing.

My last suggestion might be controversial. Tempting as it is to try fiddling with things like section headings, styles and like at the outset, I'd be inclined to get on with writing the text first. By all means use a standard set of semantic markup commands (\chapter, \section, \footnote and so forth), but leave worrying about things like fonts and the like until the basic shape of your text is clear to you, since design needs to some extent to follow content. At that point, you are going to need to make design decisions; for that you need to spend some time thinking about the sort of look you like, and why you like it, and would be well-advised to read something, like Bringhurst's The Elements of Typographic Style written by someone who actually knows what s/he's talking about when it comes to book design.

-
Don't think on customization now, leave that for later. The advantage of LaTeX is precisely that you can do such tweaks at the end, and concentrate on the contents first. (Yes, the last suggestion isn't at all controversial for me.) For including listings, I'm using the listings package (and I've heard that minted is very good). If on Unix/Linux, the bashful package can help by running your examples directly from the source and adding their output to the running text. –  vonbrand Jan 17 '13 at 12:35