Category Archives: LaTeX相关

Zim的TeX公式中使用中文

找到_Equation.tex模板文件,改成这样。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{CJKutf8}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[usenames]{color}

\begin{document}
\begin{CJK}{UTF8}{gbsn
}

% No empty lines allowed in math block !
\begin{align*}
[% equation -%]
\end{align*}

\end{CJK}
\end{document
}

插入时,用

1
2
3
\end{align*}
这里是中文
\begin{align*
}

来跳过align*环境。或者直接把模板文件中的align*环境去掉,但是这样在多数情况下不方便。

另外,如果要插入表格,也可以使用上面的方法跳过align*环境。

让Sage Notebook中的LaTeX环境支持中文

只需要修改$SAGE/devel/sage-main/build/sage/misc/latex.py,就可以让notebook中的latex环境支持中文。
测试环境:Archlinux + Sage 4.7 + TeXLive 2011

  1. COMMON_HEADER字符串的最后添加”\\usepackage{CJKutf8}\n“
  2. 文件中有三处包含”\\begin{document}\n“的字符串(注释块中的不算),在其后添加”\\begin{CJK}{UTF8}{gbsn}\n\n“
  3. 文件中有三处包含”\n\\end{document}”的字符串(注释块中的不算),在其前面添加”\n\n\\end{CJK}\n“

这样,就能在notebook的%latex环境中使用中文了。

一个新的支持latex的vim插件

Automatic (La)TeX Plugin for Vim (atp-vim)是一个新的支持LaTeX的插件。前些天刚发现时,bug还比较多,经常出错,现在的版本好多了。与latexsuite相比,有些新的功能很不错(毕竟06年以后latexsuite就没有更新过),推荐给喜欢LaTeX,VIM,Python的朋友。

完整的特性可以查阅官方的Feature List,或者手册。下面几条是我比较喜欢的。

  • 正向查找。由vim中光标处直接跳至pdf相应位置处。
  • 反向查找。由pdf跳转至vim相应源代码处。
  • 清理中间文件。这个功能实现起来不难,但是有了总是方便一点,特别是对有洁癖的人。
  • 补全命令也很丰富。

总的来说,值得一试。

ps. 目前最新的测试版是9.6.7。从SF的记录来看,最早的版本是今年3月份发布的,上来就是9.1。莫非现在流行大版本号?

7月11日补充:如果源文件所在目录的路径中包含中文,则会出现很多问题,而且很诡异。

[转]LaTeX技巧503:LaTeX的符号查找技巧

原文地址:http://blog.sina.com.cn/wangzhaoli11

很多网友问及这样的问题,latex输入的那些符号都需要命令,这些命令又记不住怎么办,我说,查手册《symbols-a4.pdf》当然,看手册还是觉得符号不好找。

那么我推荐下面的网站 http://detexify.kirelabs.org/classify.html

网站界面如下:左边手写输入 符号,右边便是识别出来 对应 手册的命令和要使用的宏包,非常方便。推荐 推荐

测试QuickLaTeX插件

据说可以添加公式了。试试
$$ E=mc^2$$

QuickLaTeX插件主页:http://www.holoborodko.com/pavel/quicklatex/
一篇介绍文章:http://www.texdev.net/2011/02/10/quicklatex-a-latex-plugin-for-wordpress/

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
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.pathreplacing
}

% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt
]
\tikzstyle{block} = [rectangle, draw, fill=blue!20,
text width=2em, text centered, rounded corners, minimum height=4em
]
\tikzstyle{line
} = [draw, -latex']
%\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
%    minimum height=2em]

\begin{tikzpicture}[scale=0.7, node distance = 2.0cm, auto]
\node [block] (problem) {\\\\\\};

\node [block, right of=problem] (model) {\\\\\\};
\path [line] (problem) -- (model);

\node [block, right of=model] (method) {数值计算方法};
\path [line] (model) -- (method);

\node [block, right of=method] (prog) {\\\\\\};
\path [line] (method) -- (prog);

\node [block, right of=prog] (comp) {\\\\\\};
\path [line] (prog) -- (comp);

\draw[decorate, decoration={brace, mirror}, very thick, blue] (0,-2) -- (3,-2);
\draw (1.5,-2.8) node {应用数学};

\draw[decorate, decoration={brace, mirror}, very thick, blue] (5.5,-2) -- (11.5,-2);
\draw (8.5,-2.8) node {计算数学};
\end{tikzpicture
}

Beamer中使用verbatim环境

\begin{frame}[fragile]

Batch Commander–自动设置TeX文件的样式

Batch Commander是一个自动设置TeX文件样式的GUI程序,这里是作者的视频讲解:Styling TeX documents with Batch Commander | River Valley TV

但是我安装不上,找不到QtPoppler这个模块。Google说可能是要装pypoppler,但是始终装不上去。哪位知道如何解决?

补充:
Batch Commander中自带了QtPoppler.so,可惜是32位的,我64位的系统用不了……
后来在这里:http://forum.ubuntuusers.de/topic/python-qt-frontend-templatesystem-fuer-latex-/#post-1959666,找到pypoppler-qt4源码,里面的so文件也是32位的。又安装了一堆依赖才编译成功。

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

2011-4-19补充:
一个文件名交换前后两部分的例子:
rename ‘s/(.*)(2009\d*)/$2$1/’ *
这个命令处理中文有问题,也可能是我没有找对参数。

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
37
\usetikzlibrary{calc}
\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
}

无觅相关文章插件,快速提升流量