Wednesday, January 25, 2006

 

Some Tips for Latex

1.
将一段或多段文字标为注释

\if(0)

text

\fi

2.
Tips and tricks for LaTeX and friends

From http://fauskes.net/nb/latextips/

TeX, LaTeX, BibTeX and friends, are a constant source of joy and frustration. This growing collection of tips and tricks is an attempt to document some of the things I have learned working with these wonderful tools. This page is just one of many similar LaTeX tips and tricks pages on the net. Hopefully you'll find something useful here.

Numbering
Disabling section numbering without removing them from the table of contents
LaTeX enumerates by default all sections. It is possible to disable numbering of a specific section by adding an asterisk (*) after the section command like this:

\section*{Introduction}
\subsection*{Test}However, when you do this, the section is not added to the table of contents. Sometimes you want to disable section numbering but still need to generate a table of contents, or you want to have bookmarks in the generated PDF file. Add this code at the start of your document, and your problem is solved:

% disables chapter, section and subsection numbering
\setcounter{secnumdepth}{-1} Margins
Marginal notes
Notes in the page margins are easily created with the command

\marginpar{marginal note}
Putting stars in the margin
Here's a handy command for displaying a user-specified number of stars in the margin. Useful for ratings and such.

% nstar is a command for drawing n stars in the margin. Useful for ratings.
% Requires the 'ifthen' package
\newcounter{scount} % create counter
\newcommand{\nstar}[1]{%
\setcounter{scount}{#1}% initialize counter
\marginpar{\hfill % move content closer to the main text
\whiledo{\value{scount}>0}
{{\Large{$\star$}}\addtocounter{scount}{-1}}
}
}The stars are not always placed where expected, so some experimentation may be necessary. Here's an example on how to use the \nstar command:

\paragraph{Item A} Regulari quam ti del coalescent \nstar{3}
\paragraph{Item B} Li nov lingua franca va \nstar{2}
\paragraph{Item C} A un Angleso it va \nstar{4}The final result will look like this:


Graphics
How to include graphics in a LaTeX document
Many newcomers to LaTeX find it difficult and confusing to include graphics in LaTeX documents. Common questions are: What format should I use? Why won't my graphics work with PDFLaTeX? What is EPS? Below are a few links to some excellent resources that will answer most of the common questions.

Strategies for including graphics in LaTeX documents
Using Imported Graphics in LaTeX and pdfLaTeX
Graphics for Inclusion in Electronic Documents
Using LaTeX in Matlab graphics
Matlab is a superb tool for advanced plotting of data. It can save graphics in the EPS format, which is perfect for inclusion in LaTeX documents. Matlab has some support for TeX syntax in annotations. However, the result does not look that good and the typography is different from LaTeX's. Fortunately there is a solution to this problem.

LaPrint is a neat Matlab script for saving figures in a LaTeX-friendly format. The script replaces all labels, text and annotations with LaTeX markup, which are subsequently processed by LaTeX. Read all about LaPrint's features in the documentation. Here's a small example of LaPrint in use:

theta = -pi:.1:pi;
y = sin(theta)./cos(theta);
plot(theta,y)
xlabel('$\theta$'); ylabel('$y$')
text(-1,20,'\LaTeX')
set(gca,'XTick',-pi:pi/2:pi)
set(gca,'XTickLabel',{'$-\pi$','$-\frac{\pi}{2}$','0', ...
'$\frac{\pi}{2}$','$\pi$'})
title('$y(\theta) = \frac{\sin \theta}{\cos \theta}$')
laprint(1, 'demofig') % Use LaPrint to save figureThe Matlab code above produces the following figure after some processing by LaTeX.


An interesting alternative to LaPrint is fig2tex. This Matlab script replicates Matlab figures using LaTeX and macros from the PSTricks package.

PDF
Hyperlinks and bookmarks with the hyperref package
One of the nice things about PDF documents is the ability to include hyperlinks and navigation in the document. Hyperref is a package for making documents with live links in PDF and HTML output formats. Here's an example on how to set up hyperref:

\usepackage{hyperref}
\hypersetup{%
pdftitle = {Document title},
pdfkeywords = {pdf, hyperref, bookmarks},
pdfauthor = {Kjell Propell}
}Hyperref has many features for manipulating the generated PDF document. My favourite is the ability to automatically generate tree structured bookmarks from the table of contents. It also inserts hyperlinks to figures, tables and references.

Hyperref defines several useful macros for inserting url's:

Take a look at my \href{http://fauskes.net}{web site}!
See \url{http://www.fauskes.net} for more information. An important thing to remember is that PDF bookmarks don't understand special LaTeX markup. If you use mathematics in for instance a section title, the hyperref will complain. A special macro \texorpdfstring is provided to solve the problem. Example:

\section{\texorpdfstring{$H$_2$O}{Water}}

Using LaTeX and PDF for presentations
Tired of using PowerPoint? LaTeX and PDF can be used to create very impressive presentations. Michael Wiedmann has put together a nice overview of some of the possibilities for creating screen presentations. Here are a few of them:

Beamer
Prosper. There's also a patch called HA-prosper that adds more possibilities and fixes some bugs.
Seminar
Web
Powerdot
Which package to use is a matter of personal taste. The Web package is probably the easiest to use for simple presentations. A nice introduction to the HA-prosper package is available in the PracTeX Journal, no. 2 (2005)

A solution to the annoying Adobe Acrobat open file lock problem
Adobe Acrobat has a very annoying feature when generating PDF documents with LaTeX: It puts a lock on the file while it's open in the viewer. This requires you to close the document before you can rebuild the document. Editors like TeXnicCenter can do this automatically, but when the document is reopened in the viewer, it often display the first page of your document. This is a bit irritating if you are working on a different page.

There is a workaround to this problem in Acrobat. Press the "Previous View" button or use the Alt - Left arrow shortcut. Acrobat will then reopen the document and navigate to the page you were viewing before the document was closed.

Another solution is to use a different program for viewing PDF files. A good choice is GSView. GSView automatically detects changes to the document and updates its display while staying on the current page. This saves you a few keystrokes. GSView is not as streamlined as Acrobat, but it's good enough for verifying the output from pdflatex while writing and debugging a document.

A tip for TeXnicCenter users. It's quite easy to modify your build profile to use GSView instead of Adobe Acrobat. Take a look at the Viewer tab in Build->Define output profiles. Remember to set the "Close document before running (La)TeX" option to "Do not close". Click on the image on the left to see how I have configured my viewer. The (La)TeX and postprocessor tabs have the same setting as the LaTeX => PDF profile.

(按:下略)

3.
remove the page number of IEEE template

put the following after \maketitle

% for title page
\thispagestyle{empty}

% for all other pages
\pagestyle{empty}

4.
发信人: jjgod (jjgod), 信区: TeX
标 题: Re: Beamer里可以引用外部的excel文件吗?
发信站: 水木社区 (Thu Aug 10 16:34:41 2006), 站内

\usepackage{hyperref}

...

文档中

\href{file:///C:/abc.xsl}{here is a Excel document..}
【 在 my7Smth (mySmth) 的大作中提到: 】
: 能否给出具体实例代码,我再用户手册里找不到

--

※ 来源:·水木社区 http://newsmth.net·[FROM: 219.239.227.*]

发信人: my7Smth (mySmth), 信区: TeX
标 题: Beamer里可以插入视频吗?
发信站: 水木社区 (Tue Aug 8 21:35:40 2006), 站内

想要插入一段视频演示

发信人: matliu (matlab), 信区: TeX
标 题: Re: Beamer里可以插入视频吗?
发信站: 水木社区 (Tue Aug 8 21:50:42 2006), 站内

usepackage movie15

\begin{frame}\frametitle{一维傅里叶变换动态显示}
一维傅里叶变换动态显示:

\movie[width=8cm,height=6cm,poster]{一维傅里叶变换动态显示}{example1.avi}
\end{frame}

参见下面的分析

http://darkwing.uoregon.edu/~noeckel/PDFmovie.html

PDF with animations
Including animations in PDF using LaTeX
The Portable Document Format (PDF) is much more than just a substitute for paper. While printable documents are thought of as static, PDF can be dynamic and interactive. Recently, there have been reports on a new technology called livepaper (sorry, couldn't find a good link in English) which is built on Flash, claiming to be better than E-paper and HTML because of its multimedia features. But I cannot find anything in those "innovations" that PDF can't already do (see for example these interactivity demos). In fact, since Adobe has acquired Macromedia, some convergence of PDF and Flash might be expected in the future. But if you go through my example on this page, it will be clear that PDF all by itself at this point in time has all the features a multimedia author could ask for.

The context of this page is the problem of how to prepare scientific/technical documents. If you have looked at my suggestions for doing scientific presentations using Apple's Keynote 2, you should be convinced by now that LaTeX is an essential ingredient for any computer-based talk with mathematical content.

In particular, I included some links to LaTeX-based PDF presentation tools that can do almost anything that Keynote can do, based on the power of Adobe Reader.

The movie15 Package
However, one thing that isn't explained very well on other web sites is how to put multimedia content into PDF presentations. If you look at the manual for the LaTeX beamer class, there is in fact a rather detailed description of the necessary commands for movie or sound inclusion. Use that approach if you are developing a really fancy presentation.

On this page, I'll describe the approach that is best suited for a small, "bare-bones" presentation without much stylistic overhead. To do this, you should use the LaTeX style called movie15.sty created by Alexander Grahn (as of October 2005, this package is fully functional with Mac OS X). To check whether your LaTeX installation contains this style, just typeset the movie.tex file below and see if it gives you an error message. In that case, you'll need to donwload the style file:

movie15.zip from the CTAN archive.
Installation is simple: move movie15.sty to a place where latex can find it (i.e., in a local texmf directory), and invoke texhash to make latex aware of the new file (if you want to test this first, just put the style file into the same directory as your tex document and invoke pdflatex). The movie15 download also includes documentation and an example. In the following, I'll walk you through my own example.

How is it done?
Prerequisites
PDF movies can be displayed with Adobe Reader. In case you encounter problems on a Mac running Tiger (OS X 10.4+), make sure you have the most recent version (7.05 or higher) of Adobe Reader. The Preview Application is not an alternative here because it does not handle multimedia plugins. There are no problems with older version of Adobe Reader on Mac OS Panther, as far as I can tell.

Also note that you cannot use acroread to display multimedia embedded with the help of this package. In other words, Linux platforms can be used only to create the PDF movies, but not to present them.

Creating the files
For several years, the way I've been putting movies into PDF presentations has been based on direct application of \pdfannot or \pdfmark - commands understood by pdflatex which allow you to write PDF code. The style movie15.sty uses these commands to create a very flexible and user-friendly way to do this without having to leave the LaTeX level. This package is able to use the features of the newest Adobe Reader, including 3D virtual reality interactivity. Here, I'll address only traditional movie playback to keep things simple.

The method is best described by example.

Assume you have the following movie in MPEG or AVI format (actually, I have an mp4 movie on this web page but will use avi for the PDF example below):

To try the example below, download one or both of these movie files:
Circle-m-increase3.avi
Circle-m-increase3.mp4
by right-clicking on the file name.

AVI format is used for this example because I'm hoping it is more compatible with media players, but especially for web documents I would recommend MPEG encoding. If you want, you can modify the example below by replacing .avi with .mp4 in the LaTeX source. To create MPEG format, here are some tools:

QT amateur is a free movie player for Mac OS X which can export various movie and image file formats (even in batch mode). It requires Quicktime 7 to be installed on your machine.
Apple's Quicktime Pro application has more flexibility but it's not free.
If you are comfortable with command-line UNIX tools, there are the free packages mpeg2vidcodec or mpegencode, available for Mac from the porting system fink.
For additional information, see the pages on making movies.

Flash movies work, too, and this opens additional possibilities for interactivity in your PDF document.

You can see how I embedded the movie into the HTML code of this very page, and now we want to do the exact same thing with a PDF file by using pdflatex.
To do this, create a LaTeX file (named, e.g., movie.tex) in the same directory as the movie, containing the following:
\documentclass[12pt,landscape]{article}
\usepackage{geometry}
\geometry{verbose,letterpaper}
\usepackage{movie15}
\usepackage{hyperref}
\begin{document}
Whispering-gallery mode in a quarter circle:
\begin{figure}[ht]
\includemovie[
poster,
text=(Loading Circle-m-increase3.avi)
]{6cm}{6cm}{Circle-m-increase3.avi}
\end{figure}
\end{document}

The LaTeX file is downloadable by clicking here.
The \includemovie command is the crucial object here. Its last three arguments are the dimensions of the movie and the file name. The dimensions can be chosen arbitrarily and will cause the movie to be rescaled accordingly.

The commands related to geometry and landscape are not essential; they just turn the output page sideways for on-screen viewing. I added the package hyperref even though it gets loaded automatically when pdflatex is invoked. The reason I put this in is that the file can then be processed either using pdflatex movie (the preferred way) or using latex movie followed by dvipdf movie to create the PDF output.

In order to view the PDF with embedded movie, you need to open movie.pdf with Adobe Reader or Acrobat. The output file can also be downloaded by clicking here. The movie is automatically loaded and represented by its first frame ("poster frame"). Playback starts after you click on the picture and stops on the last frame. I didn't put in any visible movie controls because they appear to be buggy under Windows (thanks to Alexander Grahn for mentioning this). With Mac OS X, controls work fine, so you could add the option controls to \includemovie and obtain the same appearance as on this web page. Even without control buttons, one can always restart the movie by double-clicking on it (this applies to Mac; for Windows, you may just need a single click).
One more warning: we are using advanced features of PDF here, so you also need a recent version (>1.2) of pdflatex, so upgrade your tex distribution if necessary.
Observe one fascinating detail:
The movie itself is contained in the PDF file, instead of having to be shipped as a separate file. In other words, we have created something that deserves the name Portable Document Format. The caveat of course is that the movie (or any other multimedia content for that matter) will only play properly if the PDF viewer manages to find an external program that can read the embedded file format. That is why it is not advisable to use exotic or platform-specific video formats (e.g., .WMV) if you want to send your PDF file to other people.

5.
from http://blog.bs2.to/post/EdwardLee/4203

在 LaTeX 有 \mathbf{} 來讓字體變粗體。但這是在數學模式才能使用這個指令,要小心的是,他並不是數學粗體,而是數學式裡頭的『一般文字』的粗體,許多朋友誤會他是數學粗體了。

這是怎麼一回事呢?我們先來看看 \mathbf{} 的定義:

\DeclareRobustCommand\bfseries
{\not@math@alphabet\bfseries\mathbf
\fontseries\bfdefault\selectfont}
原來 \mathbf 會將數學模式取消再來取用字型,當然,此時就是一般的正常字體,而不是數學斜體了,而且也不會取用到數學模式該有的符號。
那麼怎麼辦呢?這至少有兩種解決的方式, 一個是使用 bm package 的 \bm 指令,一個是使用amsmath package 的 \boldmath 指令。

...
\usepackage{amsmath,bm}
...
$\bm{f(x,y) = 3(x+y)y / (2xy-7)}$

\boldmath
$f(x,y) = 3(x+y)y / (2xy-7)$
\unboldmath
...

這才是正確的。以上要詳細比較,請 click 圖檔放大觀察,或自行寫個簡單的 LaTeX 碼測試一下就知道了。其他還有 \mathsf{}、\mathtt{}、\mathit{} 等,他們都是為了在數學模式來表現正常字體而用的,並不是真正的數學式子用字,別被他前頭 math 字樣給騙了!

6.
from http://blog.bs2.to/post/EdwardLee/2172

所謂 hyphenation,就是排版的時候為了顧及版面的整齊,有些過長的英文字,必需斷成兩半,而以 hyphen 符號(相當於減號,但表現上不一樣)來做連接,以維持整個版面左右切齊的目的。

版面的整齊,一般有兩類的做法:


在各字(word)間插入多數的空白,以達左右切齊的目的。
字(word)間空白原則上不做大幅的調整,但將過長的字以 hyphen 連接,切斷後換行。
通常這兩種方法大概都會交互運用,但有主副之別罷了。在 TeX 排版系統裡頭,則預設採取 hyphen 的方式為主。因為 Knuth 教授認為字裡行間插入過多的空白並不美觀。
但一個英文字要從什麼地方插入 hyphen 來切斷呢?這關係著文化的不同而有不同的做法,原則上是無法由電腦演算法做百分之一百來控制的,例如有許多英文字在名詞及動詞的時候各有不同的音節,電腦程式不容易很精準的判斷出這個英文字是名詞或是動詞。而 TeX 系統的 hyphen,依據的是音節,但是,是以美式英文的慣例,也就是以韋伯字典的方式。像英式英文則會需要依據牛津字典的方式,音節的分野就會有不同了。TeX 的 hyphenation,使用的是 Frank M. Liang 的演算法,但這篇文章的重點是在實際使用,所以演算法的部份就不多談了。

TeX 排版系統在這個地方留有很大的空間,預設是美式英文,可達 90% 以上的正確性,但可以依各 language 而有不同的 pattern 來做斷字的需求。例如:


\language=數目字就可以指定不同國家的 pattern 來做插入 hyphen 的工作。

當然,這不可能完全符合所需,一些細節的部份還是得手動去調整。常用的調整方式有:


\hyphenation{不做 hyphen 的字}。
\hyphenation{eva-luat-ion}:evaluation 這個單字依指定的方式做 hypphen,指定多個單字時,各單字間以空白隔開。
\lefthyphenmin=數目字:指 hyphen 左方最少要留幾個字元。
\righthyphenmin=數目字:指 hyphen 右方至少要留幾個字元。
例如:\hyphenation{oddword} 就是強迫 oddword 這個字不做 hyphen。通常,字元數少於 lefthyphenmin + righthyphenmin 的單字就不做 hyphen。預設 lefthyphenmin=2,righthyphenmin=3。也就是說 x- 及 -xx 這種 hyphen 是不會出現的,而且五個字元(2+3)以內的單字不做 hyphen。這裡要注意的是,原來就已經有 hyphen 的字就不會去另外斷字 hyphen 了,會依 hyphen 所在處來斷字。LaTeX 的 babel 系統也會針對不同語言做不同的 hyphenation 的安排。

我們要如何知道 TeX/LaTeX 怎麼去處理某個字或某篇文章的 hyphen 呢? \showhyphens{parameter} 可以顯示單字音節的分佈情形,parameter 可以是一個單字,或一整篇的文章。這時如果使用 tex/latex 去編譯文稿的話,並不會有 dvi/pdf 的輸出,但螢幕上會顯示各個單字 hyphen 的音節所在,而且也會記錄在 *.log 檔中,以便在校稿時做調整。

這裡只是簡單的介紹,將來有機會再來做更深入的探討,其實也可以把一篇測試文稿,多試驗一下各種參數的結果看是如何。

7.
from http://blog.bs2.to/post/EdwardLee/4317

LaTeX 在數學模式下會有許多一般正常文字不會出現的額外符號,例如底線、線段、弧線等等。

在 LaTeX 裡要畫 AB 線段,可以表示成:

$\overline{AB}$

但是,如果是弧線呢?這在 LaTeX 並沒有內建,需要外來的 macro。這個 macro 名稱是 arcs,它裡頭會有一個相對於 \overline 的指令:\overarc,這就是用來表示弧線的,但要非常注意的是,他並不會使用數學斜體,例如:

\usepackage{arcs}
...
$\overarc{AB}$

這當然是不合數學排版的規範,沒有使用數學斜體。那怎麼辦呢?可以使用以下的方式:

\overarc{$AB$}

$\overarc{$AB$}$

8.
from http://blog.bs2.to/post/EdwardLee/5606

波紋號在英文中普通使用上至少有兩種,一種是 tilde,他是一種重音符號,常會位於英文字母的上方;另一種是 swung dash,這才是真正的所謂波紋號,通常他是置中的,像一般我們常看到的個人網址,使用的就是這種波紋號,例如:
http://info.sayya.org/~edt1023/

這在 TeX/LaTeX 的排版上常造成一些不習慣,因為一般字型的波紋號通常有兩種,一種是 tilde(U+02DC),另一種是 asciitilde(U+007E)。在 Unicode 的命名上,U+007E 的就直接稱呼為 tilde。而在 U+02DC 的就稱呼為 small tilde。我們一般文章上要用到的波紋號是指那個大一點的 U+007E(一般在排版系統習慣上是稱為 asciitilde)。
現在問題來了,TeX 的 Computer Modern(CM) font 只有一種波紋號,那就是 Unicode 上的 small tilde,而且,置放的位置是在頂端,而一般在對應上,習慣上是對應到 U+007E,因為只有一種 tilde,兩種大小的 tilde 都是用這個唯一的 small tilde。

當然,在 TeX/LaTeX 裡頭也有其他的波紋號的符號,例如 $\sim$ 及wsuipa package 的 \midtilde。但這些符號的使用,在 pdf 檔會造成一些困擾,這在最後會提及。

在 LM(Latin Modern)字型上有所改進,把兩種大小不同的 tilde 分出來了,但在對應取用上,直接打 \~{},所取用到的仍然是那個較小的 tilde,除非使用其他的 TeX 字型編碼(例如 T1),並使用 \textasciitilde 指令,這樣才會區分出一般的 \~{} 及 \textasciitilde 的不同。

如果我們改用 LM 字型,他有 asciitilde/tilde 之分,但是我們要改用 T1 編碼,這樣兩種 tilde 才會互相正確對應到:
\usepackage{lmodern}
\usepackage[T1]{fontenc}

我們可以發現 LM 字型的 asciitilde,他雖然較大了一些,但仍然是置於頂端,這就和字型的製作有關了,像 Nimbus 字型,他就會把 asciitilde 置於近中央的地方(目前的 teTeX distribution 中 mathptmx package 是對應到 Nimbus 字型,因為 Times 字型是商業字型):
\usepackage{mathptmx}
\usepackage[scaled=.90]{helvet}
\usepackage{courier}
\usepackage[T1]{fontenc}

這也就是一般常要使用者改用 T1 編碼的原因,這樣一些多出來的字才會正確對應的到。
好了,那麼我們最常會用到的個人網址上的那個波紋號又要怎麼處理呢?如果使用另外取代的符號,那麼製作出來的 pdf 檔,雖然看起來及印表機印出來沒有問題,但是要在 pdf 檔案中做搜尋或拷貝內容時就會出問題了,因為一般的 pdf viewer 不會把他當做是一般的波紋號來處理,也就是說可能會無法處理,或者就把他當成是其他的符號來處理,而不是我們想要的 asciitilde。

這時,網址的部份請多多利用 url package,他會自動處理,將波紋號的部份強迫使用 asciitilde。如果不是網址的話,那麼真正的波紋號是要使用指令 \textasciitilde 來表現的,這樣 pdf viewer 才會把他當成是 swung dash 這種純文字形式的波紋號。

\usepackage{url}
\usepackage{mathptmx}
\usepackage[scaled=.90]{helvet}
\usepackage{courier}
\usepackage[T1]{fontenc}
[...]
\url{http://info.sayya.org/~edt1023/}
http://info.sayya.org/\textasciitilde{}edt1023/

當然,專業排版一般的慣例,網址的部份是使用 typewriter 字族,這個 url package 會自動處理。

註一:
wsuipa package 並不含 Type 1 字型,需要 Type 1 字型的話,請在此下載:
http://cle.linux.org.tw/~edt1023/tex/wsuipa-t1.tar.gz
註二:
我們是可以去修改字型本身,將 tilde 讓他置中,但請千萬小心,這在一些重音符號及數學符號上要用到,到時可能會造成走樣。

9.
from http://blog.bs2.to/post/EdwardLee/5981

我們知道 PDF 可以嵌入許多不同的檔案,這裡所謂的嵌入是屬於附件(attachment)的形式,而不是 PDF 文件要顯示出來的內容。在 LaTeX 裡頭,如果最後完稿的是 PDF 格式,那麼,為了無需另外散佈原始文稿,我們可以把這個原始純文字檔的文稿嵌入 PDF 檔中,當做是它的附件,讓原始文稿跟著 PDF 檔案跑。

在 PDF 嵌入原始文稿,依正式的規格書有兩種方式,一種是在頁面會顯示註解符號,而在這個註解符號按滑鼠右鍵會有功能表出現,可以去開檔或存檔。甚至直接 double click 這個註解圖示就可以開檔閱讀。

另外一種方式是頁面上沒有這個註解圖示,但可以由 Adobe Reader® 的功能表上 [View] => [Navigation Tabs] => [Attachments] 也會顯示出這些嵌入的檔案,從而可以開檔或存檔(前述的嵌入方式亦可以由這種方式來開檔或存檔)。

在 LaTeX 裡頭有 attachfile/attachfile2 及 embedfile 三個 package 有這樣子的功能。其中前兩者是屬於有註解圖示的,後一種則是沒有註解圖示的。我們就以最簡單的例子來看看他們是如何表現的。首先來看 attachfile package:


% vim:ts=2 sw=2 et
% attachf.tex : attachfile package test
% Edward G.J. Lee (09/02/06)
\documentclass{article}
\usepackage{attachfile}
\begin{document}
This is a test for attachfile package.

\attachfile{attachf.tex}
\end{document}
請使用 pdflatex 來編譯,以下是由 acroread 所閱覽的情形:



attachfile2 是 attachfile 的加強版,他可以支援 dvips,也就是說不一定要使用 pdflatex 來編譯。再來看看 embedfile package:


% vim:ts=2 sw=2 et
% embedf.tex : embedfile package test
% Edward G.J. Lee (09/02/06)
\documentclass{article}
\usepackage{embedfile}
\begin{document}
This is embedfile package test.

\embedfile[
stringmethod=escape,
mimetype=plain/text,
desc={This is embedfile package test.}
]{embedf.tex}
\end{document}
一樣,請使用 pdflatex 來編譯,而且需要 pdfTeX 1.30 以上的版本才行。以下是由 acroread 閱覽的情形:



這些 packages 使用上還算方便,而且彈性比較大,有一些參數選項可以加微調,詳細請參考它們的文件說明。另外有一種土法煉鋼的方式,就是把 PDF 指令直接寫入文稿中:


\documentclass{article}
\begingroup\pdfcompresslevel=0
\immediate\pdfobj
stream attr{/Type /SourceFile /SourceName (\jobname.tex)}
file{\jobname.tex}
\pdfcatalog{/SourceObject \the\pdflastobj\space 0 R}
\endgroup
\pdfcompresslevel=9
\begin{document}
This is a embedded source code test.
\end{document}
只要在 preamble 區加入那一段程式碼,由 pdflatex 編譯後就會自動嵌入原文稿。但是這樣嵌入的方式 acroread 並不支援,需要使用 pdfTeX 所附的一個小工具:pdftosrc(如果沒有附上,需自行由 pdftex 原始碼來編譯),他的使用方法如下:


pdftosrc sourceemb.pdf
即可,他會找到第一個找到的 Source object 來解開。

但如果只是簡單的將文件嵌入某個 PDF 檔中,也是有其他的方法,例如使用 pdftk 他不但可以將某檔案嵌入 PDF 中,也可以將他們取出來:


嵌入文件:
pdftk your.pdf attach_files your.file output your2.pdf
嵌入有註解圖示的文件:
pdftk your.pdf attach_files your.file to_page 1 output your2.pdf
取出所嵌入的文件:
pdftk your.pdf unpack_files output .
這樣也是很方便,只不過需要額外安裝 pdftk 就是了。

10.

from http://blog.chinaunix.net/u/19624/showart_117545.html

1.如何参考文献中生成[1-3]形式,而不是[1][2][3]:
a. \usepackage{cite}或者\usepackage[sort&compress]{natbib}
b. 文中引用时,\cite{aaa,bbb,ccc}
如果想生成的为上标形式,用上\usepackage[super]{natbib},但是生成的上标没有括号,要生成括号的话,需要修改宏包natbib.sty第259行,在#1两侧加上[]即可.
生成参考文献链接使用\usepackage{natbib}\usepackage{hyperref}\usepackage{hypernat},只是用hyperref,会影响[1-3]的形式,必须加上宏包hypernat.

2.如果想生成自定义的参考文献样式,可使用宏包custom-bib,具体用法:
a. 下载并安装custom-bib
b. 运行makebst.tex文件
c. 生成自定义的***.bst文件,
d. 应用到具体的\bibliographystyle{***.bst}

3如何更改title中的脚注样式(直接在导言中用\renewcommand{\thefootnote}{\arabic{footnote}}是不行的)需要在article.cls或book.cls中修改
\newcommand\maketitle{\par
\begingroup
\renewcommand\thefootnote{\@arabic\c@footnote}%fnsymbol

11.

发信人: countryangel (民工,金属盛世!), 信区: TeX
标 题: 请教,关于revtex4的作者email地址的问题
发信站: 水木社区 (Wed Feb 27 20:34:22 2008), 站内

通信作者后面加上
\email[Email:]{haha@red.semi.ac.cn}
这样在abstract page的下面就会出现通信作者的email地址

现在的问题是,模板默认是在作者名字右上角出现一个"*"
然后abstract page的页面底下也是一个星号,后面是作者的email

我投的期刊要求是,不用星号,而是用a) b) c)来表示。。。
请问这个该怎么办?

--

※ 来源:·水木社区 newsmth.net·[FROM: 221.221.27.*]

发信人: countryangel (民工,金属盛世!), 信区: TeX
标 题: Re: 请教,关于revtex4的作者email地址的问题
发信站: 水木社区 (Wed Feb 27 23:21:00 2008), 站内

已解决
不用revtex4子带的 \email

而是在作者名字后面紧跟着写: $^{a)}$ \footnotetext{a) Email: haha@haha.com}

--

※ 来源:·水木社区 newsmth.net·[FROM: 221.221.27.*]

12.

发信人: Truel (七星龙渊), 信区: TeX
标 题: Re: beamer里如何去掉右下角那堆无用按钮?
发信站: 水木社区 (Tue Feb 12 09:44:57 2008), 站内


\setbeamertemplate{navigation symbols}{}

--

※ 来源:·水木社区 newsmth.net·[FROM: 211.99.222.*]

13.

发信人: cymacs (cymacs), 信区: TeX
标 题: Re: 求助beamer里使用verbatim环境的问题...
发信站: 水木社区 (Fri Feb 29 11:54:19 2008), 站内

\begin{frame}[fragile]

【 在 winteralone (千秋春香不伦百合大好~~~) 的大作中提到: 】
: beamer里面好像不能用verbatim环境或者\verb"",一用就报错,用\texttt有时候不能达到预期的效果,比如说没办法打程序里的花括号、下划线等等,求解决办法...


--

※ 来源:·水木社区 newsmth.net·[FROM: 61.167.60.239]

14.

发信人: tangbo (tangbo), 信区: TeX
标 题: 请问a|b该怎么表示
发信站: 水木社区 (Thu Jan 24 23:02:10 2008), 站内

其中a和b部分很高,直接用$a|b$效果很丑,用\left| \right.等效果也不好
看mathtype好像用了幻影,有没有更简单的方法?

※ 来源:·水木社区 newsmth.net·[FROM: 211.99.222.*]

发信人: texlive (TeXLive), 信区: TeX
标 题: Re: 请问a|b该怎么表示
发信站: 水木社区 (Thu Jan 24 23:06:13 2008), 站内

\left. blah \middle| blah \right.

发信人: tangbo (tangbo), 信区: TeX
标 题: Re: 请问a|b该怎么表示
发信站: 水木社区 (Thu Jan 24 23:30:50 2008), 站内

呵呵,perfect,原来还有\middle

发信人: donated (吾未见好德如好色者也), 信区: TeX
标 题: Re: 请问a|b该怎么表示
发信站: 水木社区 (Fri Jan 25 12:17:31 2008), 站内

這個是e-TeX當中加入的原語.
你翻遍所有的TeX和LaTeX的高級一點的教程都不會有,呵呵,即使是大又全的TeXBook....

15.
from http://ma-yue.net/archives/110


Last Page Column Equalization

MaYue on 2004-9-13,17:48

Filed under:LaTeX

使用LaTeX的双栏(twocolumn)格式在最后一页如果不加修改,通常会左面到底,右面悬空
这样的两边不齐的样子,这通常不是我们想要的输出。如何使双栏的底端找齐呢?基本上
有如下方法:

如果文章到最后是进入到参考文献的部分,可以在你觉得应该拐弯儿的地方加入\newpage
命令。可是如果你的参考文献是用BibTeX来嵌入的话,就不好办了,虽然可以在.bbl文件
里面加入,但是如果重新编译了BibTeX的话,.bbl文件会被重新刷新。如果是使用
IEEEtran(用来向IEEE会刊投稿的样式)的style的话,可以使用IEEE提供的
\IEEEtriggeratref{x}命令,这个命令放在bibliography的前面,x就是你想要断开的文
献号码。他会在第x个参考文献前面自动加入\newpage。

如果你的文档没有参考文献,或者很少,上面的方法就不适用了。这种情况下可以用
\enlargethispage{-X.Yin}命令来使最后一页的左面栏的长度缩短。这个命令需要放在你
最后一页第一栏的文字顶部某处,X.Y就是要缩小的量。在IEEEtran中命令变成了
\IEEEtriggercmd{\enlargethispage{-5.35in}}的格式。

使用第三方的package。如:balance.sty或者flushend.sty。虽然他们都可以很方便的得
到,但是不少杂志都不太接受这种非官方的包,因为这样也许会使排版变得不够标准。所
以,很多目的都必须通过很传统的LaTeX命令来实现,这也正是深入了解LaTeX的必要性。



<< Home

This page is powered by Blogger. Isn't yours?