Sunday, December 20, 2009

LaTeX hijinx

links
latex forum  TexLive install (zenwalk)   TeX Live guide   summary of commands   general guide   general guide  latex basics   latex basics   formatting   formatting tips   font info  more font   equations   graphing information  graphing instructions   photos/graphics   complex graphs   tables  lines, boxes  templates: letters, tables  BibTeX   BibTeX  Hongzhi's Notes   convert latex to png


Note: If Perl or Tk version problems appear running tlmgr or tlmgr -gui, it might be searching on the DVD instead of the HDD installation. The way to confirm this is to run $ tlmgr update --list which will attempt to evaluate what packages could be updated by examining the database. If it comes back unable to find the database and the folder is the DVD, not the HDD, update where it looks:
$ tlmgr option location http://mirror.ctan.org/systems/texlive/tlnet
Also update tlmgr, before checking anything else.
$ tlmgr update --self



Latex

Unlike MS Word, LaTeX is not WYSIWYG, but we it's features are transparent,non-proprietary, and configurable to very fine grain. LaTeX seems slightly ungainly initially, before one understands what set of binaries they will typically use. One becomes more efficient as they learn, but the easiest approach for a noob appears to be to download a complete 2.8 GB TexLive or MiKTeX iso, that has all potential binaries and many templates. Just burn it to DVD and then install it to the hard-drive from the DVD. One will avoid encountering missing binary requirements by having a complete installation. The greatest advantage of the basic LaTeX being in ASCII text is that it is easily searchable w/grep, unlike proprietary formats (eg. Word). Additionally, publishers often produce .cls files which automatically, or nearly automatically, format one's text for the style of the journal's submission requirements. After placing in the appropriate directory, one only need change one line at the top of their document eg: \documentclass{theircls}.

tex files
The basic LaTeX file is the ascii .tex file. It can be edited with any text editor. Once complete, the source .tex is compiled into a .dvi file (device independent), but it can also be compiled into other formats, such as .pdf, .ps, .ep, etc.

tex file syntax
The default settings for margins are huge, around 2" in every direction. In the basic .tex file below, I added {geometry} package information to overcome this but, if the default geometry is desired, {geometry} can be deleted. One can create their own style sheets and call them with \usepackage, applying desired behavior across any document, similar to the way a css sheet does in an html document.

test.tex
% percents are comments
\documentclass[letterpaper]{article}
\usepackage[left=3cm,top=3cm,right=3cm,nohead,nofoot]{geometry}
\usepackage[british]{babel}
% \usepackage[T1]{fontenc} accents, umlauts, etc
% \usepackage[utf8]{inputenc} chinese characters
% \usepackage{graphicx} if photos
% \usepackage{indentfirst} indents first para in section
% \usepackage[scaled]{helvet} sans serif pt1
% \renewcommand*\familydefault{\sfdefault} sans serif pt2
\author{\LaTeX Newbie}
\title{A Quick Example}

\begin{document}
\section{Notes Wk 1}
Math 674 -- Spring 2010
\subsection{20100116 Introduction}
We review the syllabus and introductions. A primary concern seems to be the use of a calculator.\\

Here are a couple of equations that are pretty well known, the second being the quadractic formula. I'm uncertain how to make a larger space between the two equations:
\begin{displaymath}
E = mc^2
\begin{array}{*{20}c} {x = \frac{{ - b \pm \sqrt {b^2 - 4ac} }}{{2a}}} &
{{\rm{when}}} & {ax^2 + bx + c = 0} \\ \end{array}
\end{displaymath}
\noindent
Just a short follow-up text
\end{document}

If we then compiled it into a .pdf with the command, say $ pdflatex test.tex , it looks like this:



graphs and photos
Many people creates graphs or plots of equations outside LaTeX and "\include" the results, while also using a package to process it. The main packages are eepic, graphicx, and tikz. Eepic is not known to work with pdflatex, which I use to compile my docs into PDF files. It appears a simple way is to use gnuplot from the command line, and export the resulting graph as an *.eps file. In the main document, use the graphicx package ("\usepackage {graphicx}") and then, where graphics are desired, call the eps file(s) using \includegraphics with the file name to insert the graphic. Graphicx can also import jpgs pngs and the like, as described in this wiki primer.

Another option is tikz, which is actual vector graphics. The package is \usepackage{tikz}, and then the callout is \begin{figure}, which is apparently the graphics area. Nested, we use \begin{tikzpicture} with associated code then entered to create the graph. Tikz apparently is a user application layer for a program called "pgf". The info on pgf along with some typical tikz examples is available at the pgf site. Chapter 12 of the TIKZ manual there is particularly helpful for mathematics graphing, but does not manage equations and smooth curves easily. It is possible, and looks clean, as seen here.

currency symbols inside math mode
Since dollar signs are a special operator used to delimit math mode, suppose we need actual dollar signs to display in a math output? Unfortunately, the only answer I've found to date is to insert: \text{\$}

tex to html, open office, word
Link: Geico Caveman's attempt
In TexLive, tex4ht appears worthless. For straight html, I didn't find anything better than $ htlatex foo.tex . this created an html document and associated css stylesheet that properly rendered math and text. At least in Firefox. The css stylesheet was bulky for a css and a few features will not parse, notably dfrac.

combining multiple documents
I can't write it any better than this excellent post for combining multiple .tex files into a book or other larger document.

Saturday, December 19, 2009

dvd-burning burn-out

Links: Firmware info   Firmware   Latest DVRFlash
It used to be that DVD-burning was pretty straightforward under various distributions:
$ growisofs -dvd-compat -Z /dev/hdc=myvacation.iso
Mostly, all would go smoothly. However, hardware driver advances have been uneven, such as for drives and cables and I/0 ports, firmware, and the BIOS. A DVD drive might read OK, yet might encounter glitches when burning:
$ growisofs -dvd-compat -Z /dev/hdc=myvacation.iso Executing 'builtin_dd if=myvacation.iso of=/dev/sr0 obs=32k seek=0' :-[ PERFORM OPC failed with SK=3h/POWER CALIBRATION AREA ERROR]: Input/output error

A user could run a burn program (eg. Brasero) to overcome manual settings. However, the next problem is the DVD drive, which is supposed to burn at, say, 4-16x, is burning instead at about .5x. That would be something like 680 KbSec, if we agree 1x is supposed to be about 1.32 MB/Sec. This is annoying, to be sure. (Note: one good thing about Brasero, it seems a rare non-K3b burner which will do video, at least if configured properly.

Is the cable the problem, the DVD firmware... some other? The burner only working at 1/8 of its lowest burn speed is going to cause I/O problems and user delays. We could also test the burner's native capacity, as described here, to provide a rough view.

# hdparm -i /dev/sr0
Model=PIONEER DVD-RW DVR-108 , FwRev=1.18 , SerialNo=
Config={ Fixed Removeable DTR<=5Mbs DTR>10Mbs nonMagnetic }
RawCHS=0/0/0, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=13395, BuffSize=64kB, MaxMultSect=0
(maybe): CurCHS=0/0/0, CurSects=0, LBA=yes, LBAsects=0
IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 *udma4
AdvancedPM=no
Drive conforms to: Unspecified: ATA/ATAPI-2,3,4,5

* signifies the current active mode

# hdparm -I /dev/sr0

ATAPI CD-ROM, with removable media
Model Number: PIONEER DVD-RW DVR-108
Serial Number: DKDC451400WL
Firmware Revision: 1.18
Standards:
Likely used CD-ROM ATAPI-1
Configuration:
DRQ response: 50us.
Packet size: 12 bytes
cache/buffer size = unknown
Capabilities:
LBA, IORDY(can be disabled)
Buffer size: 64.0kB
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 *udma4
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=240ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* Power Management feature set
* PACKET command feature set
* DEVICE_RESET command
HW reset results:
CBLID- above Vih
Device num = 0 determined by the jumper

# hdparm -tT /dev/sr0

Timing cached reads: 1234 MB in 2.00 seconds = 616.60 MB/sec
Timing buffered disk reads: 22 MB in 3.23 seconds = 6.82 MB/sec

Speed

With an advertised 12x reading speed, a speed of about 16 MB/sec, we see that the true, uncached read speed of 6.82 MB/sec is not coming close. And, as noted above, a write speed of about .682 MB/sec, is anywhere between 1/8 to 1/32 of the advertised 4x-16x write speed range. Hmm...

DMA

The first two checks confirm UDMA (Ultra Direct Memory Access) is working, and that in fact UDMA4, one of the faster forms of UDMA, has been selected. It's also worth the reading the IDE ffile with $ cat /proc/ide/piix.

Cable

UDMA4 requires an 80 pin cable to transfer reliably at the 66 MB/Sec transfer rate. Apparently, avoiding capacitive interference is the issue for using the 80 pin over its 40 pin predecessor. I haven't opened the box, but it's unlikely that an 80 pin cable was used for this drive, since I simply cannibalized two drives from older systems when constructing the system. The 80 pin cables are more reliable as well as backwards-compatible to earlier drives. At any rate, I can note this as potentially a problem, but perhaps not a full explanation.