Archive for the ‘LaTeX相关’ Category
rename-批量重命名命令
原来还很麻烦的用for循环(Ubuntu下批量重命名),其实只用rename就够了。比如,要把所有的文件名改为小写:
rename ‘tr/A-Z/a-z/’ *
把所有文件的后缀由rm改为rmvb
rename ’s/.rm$/.rmvb/’ *
替换时,只匹配第一次找到的子串,如果要替换所有匹配到的子串,需要添加g,比如有以下文件:
1.txt,11.txt,111.txt
命令
rename ’s/1/a/’ *.txt
得到的结果是
a.txt, a1.txt, a11.txt
而,命令
rename ’s/1/a/g’ *.txt
得到的结果是
a.txt, aa.txt, aaa.txt
TikZ一例
一下午就画这么个东西:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | \begin{tikzpicture} \def\L{8} \coordinate (m) at (0.5*\L,0); \draw (m) node[below] {$m$}; \draw[->] (0,0) -- (1.2*\L,0); \node [circle,draw] (i) at (0,0) [minimum size=3cm] {}; \draw (i) node[below left] {$i$}; \node [circle,draw] (j) at (\L,0) [minimum size=3cm] {}; \draw (j) node[below right] {$j$}; \coordinate (a) at (tangent cs:node=i,point={(m)},solution=1); \coordinate (c) at (tangent cs:node=i,point={(m)},solution=2); \coordinate (b) at (tangent cs:node=j,point={(m)},solution=1); \coordinate (d) at (tangent cs:node=j,point={(m)},solution=2); \draw (a) node[above] {$A$} -- (i.center)-- (c) node[below] {$C$} -- (d) node[above] {$D$} -- (j.center)-- (b) node[below] {$B$} -- cycle; \draw[dashed] (0,0) -- (0,0.5*\L); \draw[dashed] (\L,0) -- (\L,0.5*\L); \node (l) at (0.5*\L,0.45*\L) {$l_{ij}$}; \draw[< -] (0,0.45*\L) -- (l); \draw[->] (l) -- (\L,0.45*\L); \draw (m) +(0:8mm) arc (0:22:8mm); \path (m) +(8:1.2cm) node{$\alpha_{ij}$}; \draw[dashed] (m) +($(0,0)-(a)$) -- (0,0); \draw[->] (0,0) +(0:18mm) arc (0:-22:18mm); \path (0,0) +(-8:22mm) node{$\alpha_{ij}$}; \draw[->] (0,0) -- (3,-2) node[below right] {$\overrightarrow{v}_{ij}$}; \draw[->] (0,0) +(0:8mm) arc (0:-32:8mm); \path (0,0) +(-18:12mm) node{$\beta_{ij}$}; \draw[dashed] (m) +($(0,0)-(c)$) -- (0,0); \end{tikzpicture} |
Beamer中自定义定理环境的风格继承问题
为了修改定理环境的标题,我们需要使用
\newtheorem{liti}{例}[section]
这样的命令重新定义一个新的环境。但是这样定义的liti块的风格是与theorem块相同,而不是我们想要的exampleblock的风格。
要想继承原有的block风格,先用
\theoremstyle{example}
命令切换成exampleblock的风格,再定义新的环境liti
\newtheorem{liti}{例}[section]
这样出来的块就和exampleblock的风格完全一致。
其他细节参见beamerbasetheorems.sty这个文件。
给Beamer中的图表加编号
默认的Beamer设置中,图表都是没有编号的,因为作者认为没人会关注这些编号。如果你很希望加上这个编号,可以使用:
\setbeamertemplate{caption}[numbered]

一种基于Latex语言的中文期刊双栏排版模板
LaTeX模板也能申请专利?居然还是发明专利。
一种基于Latex语言的中文期刊双栏排版模板:http://zhuanli.baidu.com/pages/sipo/20061001/17/8689afa3f9b3ab08f79f203dddeae334_0.html
虽然编写好的LaTeX模板是一件十分困难的事情,但是没想到还能申请发明专利。

解决apt依赖问题
在Ubuntu下一直是用国内朋友修改后的texlive,原来是2005,现在是2008。这样如果再要装kile这样的软件的话,就会有包依赖的问题,一直不知道怎么解决。今天在查另外一个问题的时候,无意中看到解决方案。总的来就,就是造一个假包装上。在这里,42楼:http://forum.ubuntu.org.cn/viewtopic.php?f=35&t=168940。下面还是转一下原文。
引用:
手工安装 TeX Live 后,如果还要从源里安装依赖 texlive 的软件(一个明显的例子就是 LaTeX 的编辑器 kile),就又会要求你再装源里面的那个已经被分解得比较零碎的 texlive2007。似乎是需要做一个关于 texlive 的空的假包?哪里有相关的文档,似乎不好找。
装 dummy 包的办法很简单了,过程如下:
它要装不少东西,好在不是很大,另外有我本来就需要的 MySQL。
在桌面上新建一 .ctl 个文件,比如:texlive-dummy.ctl 。
然后添加如下内容:
Package: texlive-dummy
Provides: texlive, texlive-base-bin, texlive-base-bin-doc,texlive-bibtex-extra, texlive-common, texlive-doc-base, texlive-doc-bg,texlive-doc-cs+sk, texlive-doc-de, texlive-doc-el, texlive-doc-en,texlive-doc-es, texlive-doc-fi, texlive-doc-fr, texlive-doc-it,texlive-doc-ko, texlive-doc-mn, texlive-doc-nl, texlive-doc-pl,texlive-doc-pt, texlive-doc-ru, texlive-doc-th, texlive-doc-tr,texlive-doc-uk, texlive-doc-vi, texlive-doc-zh, texlive-extra-utils,texlive-font-utils, texlive-fonts-extra, texlive-fonts-extra-doc,texlive-fonts-recommended, texlive-fonts-recommended-doc,texlive-formats-extra, texlive-full, texlive-games,texlive-generic-extra, texlive-generic-recommended, texlive-humanities,texlive-humanities-doc, texlive-lang-african, texlive-lang-all,texlive-lang-arab, texlive-lang-armenian, texlive-lang-cyrillic,texlive-lang-czechslovak, texlive-lang-danish, texlive-lang-dutch,texlive-lang-finnish, texlive-lang-french, texlive-lang-german,texlive-lang-greek, texlive-lang-hebrew, texlive-lang-hungarian,texlive-lang-indic, texlive-lang-italian, texlive-lang-latin,texlive-lang-manju, texlive-lang-mongolian, texlive-lang-norwegian,texlive-lang-polish, texlive-lang-portuguese, texlive-lang-spanish,texlive-lang-swedish, texlive-lang-tibetan, texlive-lang-ukenglish,texlive-lang-vietnamese, texlive-latex-base, texlive-latex-base-doc,texlive-latex-extra, texlive-latex-extra-doc, texlive-latex-recommended,texlive-latex-recommended-doc, texlive-latex3, texlive-math-extra,texlive-metapost, texlive-metapost-doc, texlive-music, texlive-omega,texlive-pictures, texlive-pictures-doc, texlive-plain-extra,texlive-pstricks, texlive-pstricks-doc, texlive-publishers,texlive-publishers-doc, texlive-science, texlive-science-doc,texlive-xetex, texlive-lang-other, texlive-lang-croatian, texlive-base,texlive-doc-ja, cm-super, lmodern, latex-xcolor, latex-beamer, pgf,preview-latex-style
Description: TeXlive dummy package
This package provides dpkg with the information that
there is a local TeXlive version installed.
保存后开始打包:
然后可以看见一个 deb 文件,名为:texlive-dummy_1.0_all.deb
现在就可以安装它了:
行了,下面就不用多说了,打开新立德,找到 kile 安装就是了,效果如下:
顺便把这两个文件也一并打包附赠:
被下载 90 次

CaR,GCLC,TikZ
C.a.R.和GCLC都可以算做类似几何画板的所谓动态几何软件,这里是维基百科上关于这类软件的一个比较。那张表并不完整,至少缺了是否跨平台这一栏。而这两个软件都具备以下特点:
- 免费
- 跨平台
- 支持LaTeX
另外,C.a.R.可以将动态结果输出至网页形式,只要装了Java的机器,可以直接在浏览器中操作。GCLC则有机器证明的功能,并可以将做图脚本输出为TikZ格式。
而TikZ是LaTeX上的一个宏包,可与Beamer很好的配合。
缺点是这三个软件都非常小众,无论国内还是国外,用户似乎都不多。
8月15日补充:
关于TikZ/PGF的好站(强力推荐):http://www.texample.net
几则Beamer技巧
1、列目录时,隐藏所有的小节
\tableofcontents[hideallsubsections]
2、自动压缩,以显示全部内容
\begin{frame}[shrink]
3、在每一节(或小节)前增加目录
命令\AtBeginSection[]{}和\AtBeginSubsection[]{}。比如下面两个命令可以实现在每一节前显示文档目录,隐藏所有小节标题,并高亮当前节标题,而在每一小节前显示的目录中,只会显示本节的小节标题,并高亮当前小节标题,其他节的小节标题不显示,只显示节标题。
\AtBeginSection[]
{
\begin{frame}
\tableofcontents[currentsection,hideallsubsections]
\end{frame}
}
\AtBeginSubsection[]
{
\begin{frame}
\tableofcontents[sectionstyle=show/shaded,subsectionstyle=show/shaded/hide]
\end{frame}
}
4、frametitle的两种写法
\begin{frame}
\frametitle{标题}
\end{frame}
\begin{frame}{标题}
\end{frame}
btw: 其实这些技巧在手册中都有,只是手册太长,一直没有完整的读过。结果每次都有新发现。喜欢Beamer,不单因为Beamer确实比较方便、漂亮,更重要的是Beamer的作者对于幻灯片的制作和使用有自己独到的见解。内容的组织,颜色的搭配,时间的控制,都有所涉及。让人感觉非常专业,自然产生一种信任。
Beamer文档中添加PDF文档信息(PDF document information)
默认参数下,Beamer宏包可以将文档的\title{}和\author{}字段的内容自动加入PDF文档信息(PDF document information)的相应字段中,如果还想添加主题和关键字等信息,可以使用\subject{}和\keywords{}命令。但是由于Beamer用的是hyperref宏包来实现这些功能,而hyperref宏包的这一功能并不支持中文。所以,如果你的幻灯片是中文标题、中文作者,那么PDF文档信息中将出现乱码。
一个可以接受的解决方案是,正文中仍然使用中文,但向PDF文档信息中添加英文信息。要实现这一点并不难,只需要先禁止Beamer自动添加这些信息,再由手工添加即可。具体做法如下:
- 使用参数usepdftitle,禁止Beamer自动添加这些信息,比如这样:\documentclass[usepdftitle=false,mathserif]{beamer}
- 手工添加相应信息,比如这样:
\hypersetup{CJKbookmarks=true,%
pdftitle={Computer Simulation},%
pdfauthor={Mao Ziyang},%
pdfcreator={amao@ai7.org},%
pdfsubject={Computer Simulation},%
pdfkeywords={simulation}
}
关于\hypersetup命令的其他信息,请参考:使用pdfLaTeX时,添加PDF文件属性的方法
tex4ht与bm包冲突
今天想把很早一篇论文转成word,因为几乎是不可能的,所以想先转成html,再copy到word中去。用的是那个texlive2005的绿色免安装包tex4lin.iso,开始总是出错,屏幕输出的信息看不出来是什么问题,每次都是到中间的部分就中断了。内存的问题,公式的问题,等等,能想到的都尝试了一下,怀疑有问题的代码都删除了,但是还是不 行。
无意中看了一下.log文件,猜想是\bm{*}命令出的问题,替换之后,果然就可以了。