Math@Latex
New Command Environment
\newcommand{\pderiv}[2]{\frac{\partial #1}{\partial #2}} \newcommand{\e}{\mathrm{e}} \begin{displaymath} \pderiv{^2\mathcal{L}}{{z_i^\rho}^2} = -\pderiv{\rho_i}{z_i^\rho} \left( \pderiv{v_i}{\rho_i} \frac{\e^{v_i}}{1-\e^{v_i}} + v_i \frac{\e^{v_i}\pderiv{v_i}{\rho_i}(1-\e^{v_i}) +\e^{2v_i}\pderiv{v_i}{\rho_i}}{(1-\e^{v_i})^2} \right) \end{displaymath}
LaTeX4Novice
cwtex@ubuntu-5.10
1. cwtex@GNU/Linux,必須先下載cwtex-linux,解後安裝在$HOME/texmf之中。
2. 解開後,把相關檔案 copy 至相對的目錄,在 config.ps 裡頭加一行 p +cwtex.map 執行 texhash 後就可以使用。
2'. 或 copy 至相對的目錄後,執行 texhash 後,再執行: updmap --enable Map cwtex.map 即可(兩種方式選一種來執行就可以了)。
然後下載dvipdfmx,使用csv方式:
cvs -d:pserver:anonymous@cvs.ktug.or.kr:/home/cvsroot login cvs -d:pserver:anonymous@cvs.ktug.or.kr:/home/cvsroot co dvipdfmx
因為編譯的時候,要使用libkpathsea.a的函式庫,所以在ubuntu-5.10必須下載libkpathsea-dev的套件:
apt-get -y install libkpathsea-dev
然後用./configure;make來編譯。
之後再來用作出來的dvipdfmx來編譯dvi檔,就能作出高品質的pdf檔了。
samuel@pika046:texmf$ sudo updmap --enable Map cwtex.map using config file /var/lib/texmf/web2c/updmap.cfg updmap: The options --enable and --disable work differently on Debian systems!. updmap: . updmap: You cannot use them to permanently enable or disable Map files. Instead,. updmap: you have to use the mechanism described in. updmap: /usr/share/doc/tetex-bin/README.Debian.gz. updmap: . updmap: If you don't know which lines to add to the files in /etc/texmf/updmap.d/,. updmap: press ENTER now and take the resulting line from. updmap: /var/lib/texmf/web2c/updmap.cfg. updmap: . updmap: Press ENTER to continue anyway, or Ctrl-c to quit.. using output directory /var/lib/texmf/dvips/config updmap is creating new map files using the following configuration: prefer outlines: true texhash enabled: true download standard fonts (dvips): false download standard fonts (pdftex): false download standard fonts (dvipdfm): false Scanning for LW35 support files using map file `/usr/share/texmf/dvips/tetex/dvips35.map' using map file `/usr/share/texmf/dvips/tetex/pdftex35.map' using map file `/usr/share/texmf/dvips/tetex/dvipdfm35.map' using map file `/usr/share/texmf/dvips/tetex/ps2pk35.map' Scanning for MixedMap entries: using map file `/usr/share/texmf/dvips/tetex/bsr-interpolated.map' using map file `/usr/share/texmf/dvips/tetex/bsr.map' using map file `/usr/share/texmf/dvips/cc-pl/ccpl.map' using map file `/usr/share/texmf/dvips/misc/cs.map' using map file `/usr/share/texmf/dvips/misc/eurosym.map' using map file `/usr/share/texmf/dvips/tetex/hoekwater.map' using map file `/usr/share/texmf/dvips/pl/pl.map' using map file `/usr/share/texmf/dvips/tetex/ttcmex.map' Scanning for Map entries: using map file `/usr/share/texmf/dvips/antp/antp.map' using map file `/usr/share/texmf/dvips/antt/antt.map' using map file `/usr/share/texmf/dvips/psnfss/charter.map' using map file `/usr/share/texmf/dvips/misc/cmcyr.map' using map file `/usr/share/texmf/dvips/config/context.map' updmap: map file `cwtex.map' not found. using map file `/usr/share/texmf/dvips/lucida/lucidabr.map' using map file `/usr/share/texmf/dvips/tetex/lucidabr-o.map' using map file `/usr/share/texmf/dvips/lucida/lumath.map' using map file `/usr/share/texmf/dvips/tetex/lumath-o.map' using map file `/usr/share/texmf/dvips/misc/marvosym.map' using map file `/usr/share/texmf/dvips/misc/mathpi.map' using map file `/usr/share/texmf/dvips/tetex/mathpple.map' using map file `/usr/share/texmf/dvips/tetex/mt-plus.map' using map file `/usr/share/texmf/dvips/tetex/mt-yy.map' using map file `/usr/share/texmf/dvips/omega/omega.map' using map file `/usr/share/texmf/dvips/psnfss/pazo.map' using map file `/usr/share/texmf/dvips/tetex/pxfonts.map' using map file `/usr/share/texmf/dvips/qfonts/qbk.map' using map file `/usr/share/texmf/dvips/qfonts/qcr.map' using map file `/usr/share/texmf/dvips/qfonts/qhv.map' using map file `/usr/share/texmf/dvips/qfonts/qpl.map' using map file `/usr/share/texmf/dvips/qfonts/qtm.map' using map file `/usr/share/texmf/dvips/qfonts/qzc.map' using map file `/usr/share/texmf/dvips/tetex/txfonts.map' using map file `/usr/share/texmf/dvips/xypic/xypic.map' texhash: Updating /home/samuel/texmf/ls-R... texhash: Updating /usr/local/share/texmf/ls-R... texhash: Updating /var/lib/texmf/ls-R... texhash: Updating /var/lib/texmf/ls-R-TEXMFMAIN... texhash: Updating /var/cache/fonts/ls-R... texhash: Done. Files generated in /var/lib/texmf/dvips/config: -rw-r--r-- 1 root root 8985 2006-01-24 17:08 builtin35.map -rw-r--r-- 1 root root 13102 2006-01-24 17:08 download35.map -rw-r--r-- 1 root root 15196 2006-01-24 17:08 dvipdfm_dl14.map lrwxrwxrwx 1 root root 17 2006-01-24 17:08 dvipdfm.map -> dvipdfm_ndl14.map -rw-r--r-- 1 root root 15823 2006-01-24 17:08 dvipdfm_ndl14.map -rw-r--r-- 1 root root 48306 2006-01-24 17:08 pdftex_dl14.map lrwxrwxrwx 1 root root 16 2006-01-24 17:08 pdftex.map -> pdftex_ndl14.map -rw-r--r-- 1 root root 46732 2006-01-24 17:08 pdftex_ndl14.map -rw-r--r-- 1 root root 49390 2006-01-24 17:08 ps2pk.map lrwxrwxrwx 1 root root 14 2006-01-24 17:08 psfonts.map -> psfonts_t1.map -rw-r--r-- 1 root root 28047 2006-01-24 17:08 psfonts_pk.map -rw-r--r-- 1 root root 45279 2006-01-24 17:08 psfonts_t1.map
samuel@pika046:texmf$ updmap --enable Map cwtex.map using config file /var/lib/texmf/web2c/updmap.cfg updmap: The options --enable and --disable work differently on Debian systems!. updmap: . updmap: You cannot use them to permanently enable or disable Map files. Instead,. updmap: you have to use the mechanism described in. updmap: /usr/share/doc/tetex-bin/README.Debian.gz. updmap: . updmap: If you don't know which lines to add to the files in /etc/texmf/updmap.d/,. updmap: press ENTER now and take the resulting line from. updmap: /var/lib/texmf/web2c/updmap.cfg. updmap: . updmap: Press ENTER to continue anyway, or Ctrl-c to quit..
samuel@pika046:texmf$ updmap -h Usage: updmap [option] ... [command] Valid options: --cnffile file specify configuration file --outputdir directory specify output directory --nohash do not run texhash --nomkmap do not recreate map files --quiet reduce verbosity Valid commands: --edit edit updmap.cfg file --help show this message --showoptions item show alternatives for options --setoption option value set option where option is one of dvipsPreferOutline, LW35, dvipsDownloadBase35 or pdftexDownloadBase14 --enable maptype mapfile add or enable a Map or MixedMap --disable mapfile disable Map or MixedMap for mapfile --listmaps list all active and inactive maps
Latex寫作
為了要寫論文格式,才得知國際上的物理期刊,其論文是用revtex4的規範來制定。revtex4是由美國物理學會所推廣的一種期刊論文寫作格式的標準規範,目的是為了讓全世界的物理論文,在寫作及閱讀到,達到統一的方式,方便物理資訊的流通,所以如果想要從事物理領域,成為終身職業的話,熟悉revtex4是需要的。
另外如果想要將論文,寫成類似科學上的文件,是透過GSW Latex(Get Started with Latex)來寫作,排版出來的效果不錯,可以再深入研究,以下是它的premable部份。
\documentclass[a4paper,12pt]{article} \addtolength{\textwidth}{50pt} \addtolength{\evensidemargin}{-25pt} \addtolength{\oddsidemargin}{-25pt} \def\displayandname#1{\rlap{$\displaystyle\csname #1\endcsname$}% \qquad \texttt{\char92 #1}} \def\mathlexicon#1{$$\vcenter{\halign{\displayandname{##}\hfil&&\qquad \displayandname{##}\hfil\cr #1}}$$} \usepackage{geometry} \geometry{verbose,a4paper,tmargin=1.5cm,bmargin=1.5cm,lmargin=2cm,rmargin=2.5cm} \usepackage[dvips]{graphicx} \usepackage[dvipdfm,colorlinks=true,linkcolor=blue]{hyperref} \newenvironment{num} {\leftmargini=6mm\leftmarginii=8mm \begin{enumerate}}{\end{enumerate}} \begin{document} \title{Keynotes of Jackson's EM-Dynamics} \author{呂俊興\thanks{\href{mailto:samuel@nchc.org.tw}{Software developer}}} \date{2nd Edition\\[3pt] Copyright \copyright\ Samuel Lu 2005} \maketitle \tableofcontents
在編譯中文的tex文件,是透過cwTex系統來排版,流程如下:
- cwTex file.ctx
- latex file.tex
- dvipdfmx file.dvi
- file.pdf
其中是用dvips來處理圖形,如果是.jpg,要使用makebb,先作bounding box,.gif則可以先轉成.eps,然後直接再匯入tex檔案中即可。
Tex/LaTex Syntax
thebibliography \begin{thebibliography}{widest-label} \bibitem[label]{cite_key} . . . \end{thebibliography} The thebibliography environment produces a bibliography or reference list. In the article class, this reference list is labelled "References"; in the report class, it is labelled "Bibliography". widest-label: Text that, when printed, is approximately as wide as the widest item label produces by the \bibitem commands. \bibitem \bibitem[label]{cite_key} The \bibitem command generates an entry labelled by label. If the label argument is missing, a number is generated as the label, using the enumi counter. The cite_key is any sequence of letters, numbers, and punctuation symbols not containing a comma. This command writes an entry on the .aux file containing cite_key and the item's label. When this .aux file is read by the \begin{document} command, the item's label is associated with cite_key, causing the reference to cite_key by a \cite command to produce the associated label. \cite \cite[text]{key_list} The key_list argument is a list of citation keys. This command generates an in-text citation to the references associated with the keys in key_list by entries on the .aux file read by the \begin{document} command. The optional text argument will appear after the citation, i.e. \cite[p. 2]{knuth} might produce `[Knuth, p. 2]'. \nocite \nocite{key_list} The \nocite command produces no text, but writes key_list, which is a list of one or more citation keys, on the .aux file. Using BibTeX If you use the BibTeX program by Oren Patashnik (highly recommended if you need a bibliography of more than a couple of titles) to maintain your bibliography, you don't use the thebibliography environment. Instead, you include the lines \bibliographystyle{style} \bibliography{bibfile} where style refers to a file style.bst, which defines how your citations will look. The standard styles distributed with BibTeX are: alpha Sorted alphabetically. Labels are formed from name of author and year of publication. plain Sorted alphabetically. Labels are numeric. unsrt Like plain, but entries are in order of citation. abbrv Like plain, but more compact labels. In addition, numerous other BibTeX style files exist tailored to the demands of various publications. The argument to \bibliography refers to the file bibfile.bib, which should contain your database in BibTeX format. Only the entries referred to via \cite and \nocite will be listed in the bibliography. theorem \begin{theorem} theorem text \end{theorem} The theorem environment produces "Theorem x" in boldface followed by your theorem text.
tabular \begin{tabular}[pos]{cols} column 1 entry & column 2 entry ... & column n entry \ . . . \end{tabular} or \begin{tabular*}{width}[pos]{cols} column 1 entry & column 2 entry ... & column n entry \ . . . \end{tabular*} These environments produce a box consisting of a sequence of rows of items, aligned vertically in columns. The mandatory and optional arguments consist of: width Specifies the width of the tabular* environment. There must be rubber space between columns that can stretch to fill out the specified width. pos Specifies the vertical position; default is alignment on the centre of the environment. t - align on top row b - align on bottom row cols Specifies the column formatting. It consists of a sequence of the following specifiers, corresponding to the sequence of columns and intercolumn material. l - A column of left-aligned items. r - A column of right-aligned items. c - A column of centred items. | - A vertical line the full height and depth of the environment. @{text} - This inserts text in every row. An @-expression suppresses the intercolumn space normally inserted between columns; any desired space between the inserted text and the adjacent items must be included in text. An \extracolsep{wd} command in an @-expression causes an extra space of width wd to appear to the left of all subsequent columns, until countermanded by another \extracolsep command. Unlike ordinary intercolumn space, this extra space is not suppressed by an @-expression. An \extracolsep command can be used only in an @-expression in the cols argument. p{wd} - Produces a column with each item typeset in a parbox of width wd, as if it were the argument of a \parbox[t]{wd} command. However, a \\ may not appear in the item, except in the following situations: inside an environment like minipage, array, or tabular. inside an explicit \parbox. in the scope of a \centering, \raggedright, or \raggedleft declaration. The latter declarations must appear inside braces or an environment when used in a p-column element. *{num}{cols} - Equivalent to num copies of cols, where num is any positive integer and cols is any list of column-specifiers, which may contain another *-expression. These commands can be used inside a tabular environment: \cline \cline{i-j} The \cline command draws horizontal lines across the columns specified, beginning in column i and ending in column j, which are identified in the mandatory argument. \hline The \hline command will draw a horizontal line the width of the table. It's most commonly used to draw a line at the top, bottom, and between the rows of the table. \multicolumn \multicolumn{cols}{pos}{text} The \multicolumn is used to make an entry that spans several columns. The first mandatory argument, cols, specifies the number of columns to span. The second mandatory argument, pos, specifies the formatting of the entry; c for centred, l for flushleft, r for flushright. The third mandatory argument, text, specifies what text is to make up the entry. \vline The \vline command will draw a vertical line extending the full height and depth of its row. An \hfill command can be used to move the line to the edge of the column. It can also be used in an @-expression.
Graphics Latex
以為解決了png的問題,gif格式的圖檔應該是水到渠成,自然也是沒問題才對,但是想錯了,因為仍然無法在我的系統中,放入TeX文件內,既使是轉成eps的圖檔,仍然會出錯,在latex編譯的時候,就己經是無法處理了,我想是否是latex的版本不能夠處理,還得查證,所以最後只能用jpg格式來解決這個問題了。
找了好久才知道,原來dvipdfmx對於png的支援,還不太完整,原本加入
\usepackage[dvips]{graphicx} \includegraphics[width=.3\textwidth]{images/MagicSquare.png}
然後用bmeps作出bb檔,編譯即可,但是一直都編譯不過,後來才知道,只要是png的圖檔,dvipdfmx的支援就很差,最好是用jpg的格式,比較沒有問題,dvipdfmx的支援也較完整。
為了要將jpeg的圖檔,放入tex檔案之中,選擇使用\usepackage[dvips]{graphicx}的呼叫方式,但是即使是將jpeg的圖檔,己經轉成了eps,還是無法放入tex文檔之中,在編譯時會出錯,找了好久才知道問題出來沒有bounding box,上網查詢才得知需要bmeps這個utils來作出bb檔。
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/bmeps login cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/bmeps co -P modulename
無法使用cvs的方式下載,所以只好在中心下載tarball,並且configure/make作出bmeps的執行檔,使用方式如下:
Usage: env LD_LIBRARY_PATH=~/Bmeps ./bmeps FarmGrid.jpg FarmGrid.bb
因為bmeps會呼叫libbmeps.so.1.2,所以將路徑指出來,餵給它自己去尋找此so檔,可以在Usage找到更多使用的方式。
這樣一來,不管格式是PNG/JPEG/NetPBM,都可以先作出Bounding Box,讓latex計算作出dvi檔。
http://png2pdf.sourceforge.net/usage.html 如果要直接使用png,來放入tex文件之中,通常是使用makebb,來作出Bounding Box的訊息,讓latex可以知道大小,之後才放整個版面的計算。但是png2pdf這個style,可以直接使用png,來放入tex文件中。\documentclass[12pt,a4paper,titlepage]{article} \usepackage{ifpdf} % LaTeX or pdfLaTeX \usepackage{color} % we want to use background color \usepackage{graphicx} \ifpdf \usepackage{background} % for the background effects, PPower4 necessary \fi \definecolor{bgred}{rgb}{1.0,0.501961,0.501961} ... \begin{document} ... \begin{figure} {\centering \includegraphics[width=5cm]{stefan_255_rgba.png} \caption{Some caption} \label{fig:some-label} } \end{figure} ... \end{document}圖形的支援 http://www.ctex.org/documents/latex/graphics/graphics.html 13.3 非EPS圖形文件 EPS 格式的圖形文件可以很容易的插入到 LATEX 文件中, 而非 EPS 格式的圖形文件則不是將插圖命令中的文件名替換一下就可以的。 對於不同的圖形驅動來說,所支持的圖形格式也不盡相同。而不同版本的 TEX 軟件也有各自支持的非 EPS 格式圖形。一般來說,除了 .png 格式的圖形文件外,其它的非 EPS 格式圖形基本上只有一兩種圖形驅動 支持直接使用它們。更多的情況是需要先轉換為 EPS 格式的圖形文件 13.2再插入到 LATEX 文件中。 這樣就要求有相應的圖形格式轉換工具。儘管使用非 EPS 格式的圖形文件 不如 EPS 圖形文件簡單方便,但由於它們可能比 EPS 文件要小,而一些 繪圖軟件也不能生成 EPS 文件,所以有時還是希望在 DVI 文件轉換為 PS 文件時再對其進行格式轉換。如果使用 dvips,這種即時轉換的命令可用 \DeclareGraphicsRule來給出。例如用這種方法將 file2.gif 加 到 LATEX 文檔中需要以下幾步: 1. 找到一個支持命令行方式的 GIF 到 EPS 的轉換工具(假設 為 gif2eps)。 2. 建立一個註明 file2.gif 自然大小的 BoundingBox 文件。為此, 1. 用 ebb file2.gif 直接得到 BoundingBox 文件13.3。 2. 將 file2.gif 轉為 PostScript 文件,若其中有 BoundingBox 行, 則將此行存放到文件 file2.gif.bb 中,否則,可按照 第 3.3 節的方法來計算 BoundingBox 並將所得 到的結果放在 file2.gif.bb 中的 %%BoundingBox: 後。然後將 PostScript 文件刪除。 3. LATEX 文件中,在 \includegraphics 命令前,加入圖形規則: \DeclareGraphicsRule{.gif}{eps}{.gif.bb}{`gif2eps #1} 當遇到 \includegraphics{file.gif} 時, LATEX 從 file.gif.bb 中讀取 BoundingBox 並告訴 dvips 使用 gif2eps 來將 file2.gif 轉為 EPS 文件。 Subsections * 13.3.1 GIF 的例子 * 13.3.2 對非 EPS 圖形的直接支持 13.3.1 GIF 的例子 由于插入非 EPS 格式的图形所需的命令依赖于操作系统和图形格式转换程序, 在此提供两个 Unix 系统下常用的转换程序的例子。 \DeclareGraphicsRule{.gif}{eps}{.gif.bb}{`convert #1 'eps:-' } \begin{figure} \centering \includegraphics[width=3in]{file2.gif} \caption{GIF Graphic} \end{figure} 这里使用 convert(包含在 ImageMagick 中)来 将 GIF 转为 EPS。而命令: convert file2.gif 'eps:-' 将 file2.gif 转为 EPS 格式的图形并输出到标准输出。 另一方法是使用 giftoppm, ppmtopgm 和 pgmtops 来 将 GIF 转为 EPS。只需在上例中将图形规则改为: \DeclareGraphicsRule{.gif}{eps}{.gif.bb}% {`giftoppm #1 | ppmtopgm | pgmtops} 13.3.2 对非 EPS 图形的直接支持 虽然 LATEX 和 dvips 不断地被要求直接支持非 EPS 图形并使 得如同 EPS 图形一样简单方便。的确,这样做会带来不少方便,但却存在 着不少问题。 * 因为 LATEX 是通过从 EPS 文件中读取 BoundingBox 来确定图形 文件的大小的,加上 LATEX 只能读取 ASCII 文件,所以其它的非 EPS 图形 文件(绝大多数是二进制文件)会阻碍 LATEX 获取图形大小的信息。 * 进一步讲,支持非 EPS 图形要求 dvips 具有图形格式转换的 能力(GIF-to-PS, TIFF-to-PS, 等)。这需要大量的编程和维护工作。 有鉴于此, dvips 提供调用外部图形转换程序的机制而不是 直接支持非 EPS 图形文件。这种机制允许 LATEX 通过设置 \DeclareGraphicsRule 来使 dvips 调用指定的外部图形转换程序。 这样使用者可自己选择图形转换程序, dvips 也不用捆绑 一些图形转换功能,从而比直接支持非 EPS 图形文件更具灵活性。 仅管 LATEX 和 dvips 一般不支持直接插入非 EPS 的图形, 也还是有几个例外: 1. 如果 dvips 编译时用了参数 -Demtex,它将支持 一些 EmTEX 的 \special 命令,允许直接插入 PCX, BMP 或 MSP 位图。 2. Macintosh 下的共享 TEX/LATEX 软件 Oztex2.1 中, DVI 到 PS 的 转换程序 OzDVIPS 允许通过 \special 命令来使用 MacPaint 和 PICT 文件。详见 http://www.kagi.com/authors/akt/oztex.html 3. 一些商业版本的 LATEX 支持非 EPS 的图形。 1. Macintosh 下的 Textures 支持 PICT 图形。详见 http://www.bluesky.com/ 2. Y&Y 的 Windows 版本的 TEX 中, DVI 到 PS 的转换程序 DVIPSONE 支持 TIFF 图形。详见 http://www.YandY.com/ 即使上述方法中, TEX 仍然无法直接从二进制的图形文件中获得 其图形的大小。为使 LATEX 能正确地给所插入的图形分配空间, 使用者必须用 .bb 文件或在 \includegraphics 中 用 bb 选项给出图形的大小。