2014年5月25日星期日

Latex 下 beamer 生成幻灯片,书签乱码,文件属性不能显示

Latex 下 beamer 生成幻灯片使用中文时,书签是乱码,同时用adobe reader打开时,文件属性不能显示,可能是编码引进的
/beamer/base/beamer.cls中找到:
\PassOptionsToPackage{bookmarks=true,%
  bookmarksopen=true,%
  pdfborder={0 0 0},%
  pdfhighlight={/N},%
  unicode=true,% 加入这样的一行
  linkbordercolor={.5 .5 .5}}{hyperref}

2014年5月18日星期日

Latex 基础3之符号


符号

用途

显示方法
% 注释符号 \%
\ 命令前导符号 \textbackslash
$ 数学模式符 \$
# 参数符 \#
{ 必要参数符或组合起始符 \{
} 必要参数符或组合结束符 \}
^ 上标符 \^{}
_ 下标符 \_
~ 空格符{} \~
& 表格分列符 \&

显示方法,也可统一使用\verb"%";

usage of for in windows cmd

help of  for under cmd

Pay attention to the NOTE part

Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]
  •   %variable                     Specifies a single letter replaceable parameter.
  •   (set)                             Specifies a set of one or more files.  Wildcards may be used.
  •   command                     Specifies the command to carry out for each file.
  •   command-parameters   Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead of %variable.
Variable names are case sensitive, so %i is different from %I.
NOTE:

  • under cmd,use %variable           
  • under *.bat,use%%variable.all the examples below displayed this way.
  • commands,like for/FOR,in/IN,/d, are NOT case sensitive

If Command Extensions are enabled, the following additional forms of the FOR command are supported:

1) FOR /D %variable IN (set) DO command [command-parameters]


    If set contains wildcards, then specifies to match against directory names instead of file names.
NOTE:

  • /d means directory only,files` names are not included
  • /d sub directories are not listed, current directory only
e.g.
for /d %%i in (*) do @echo %%i
for /d %%i in (???) do @echo %%i

2) FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]


 Walks the directory tree rooted at [drive:]path, executing the FOR statement in each directory of the tree.
 If no directory specification is specified after /R then the current directory is assumed.
 If set is just a single period (.) character then it will just enumerate the directory tree.
NOTE:

  • walks the directory in recursive way

e.g.
for /r C:\ %%i in (*.exe) do @echo %%i   
//list all the *.exe files under C:\ and its sub directories.

for /r %%i in (*.exe) do @echo %%i
//list all the *.exe files under current directory.

3) FOR /L %variable IN (start,step,end) DO command [command-parameters]

    The set is a sequence of numbers from start to end, by step amount.
    So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would generate the sequence (5 4 3 2 1)

e.g.
for /l %%i in (1,1,5) do @echo %%i

FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]

    or, if usebackq option present:

4) FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
    FOR /F ["options"] %variable IN ('string') DO command [command-parameters]
   FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]

file-set is one or more file names.  Each file is opened, read and processed before going on to the next file in file-set. Processing consists of reading in the file, breaking it up into individual lines of text and then parsing each line into zero or more tokens.
The body of the for loop is then called with the variable value(s) set to the found token string(s).  By default, /F passes the first blank separated token from each line of each file. Blank lines are skipped.  You can override the default parsing behavior by specifying the optional "options" parameter.  This is a quoted string which contains one or more keywords to specify different parsing options. The keywords are:

        eol=c                  - specifies an end of line comment character (just one)
        skip=n                - specifies the number of lines to skip at the beginning of the file.
        delims=xxx         - specifies a delimiter set. This replaces the default delimiter set of space and tab.
        tokens=x,y,m-n  - specifies which tokens from each line are to be passed to the for body for each                                             iteration. This will cause additional variable names to be allocated.  The m-n form is                                       a range, specifying the mth through the nth tokens.  If  the last character in the                                               tokens= string is an asterisk, then an additional variable is allocated and receives the                                     remaining text on the line after the last token parsed.
        usebackq          - specifies that the new semantics are in force, where a back quoted string is executed                                      as a command and a single quoted string is a literal string command and allows the                                        use of double quotes to quote file names in file-set.

    Some examples might help:
for /f "delims=\n" %%i in (file.txt) do echo %%i
//type the file.txt line by line 

FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k
 would parse each line in myfile.txt, ignoring lines that begin with a semicolon(eol=;), passing the 2nd and 3rd token from each line to the for body, with tokens delimited by commas and/or spaces("delims=, " NOTE: there is a space '' " after the  comma).
Notice the for body statements reference %i to get the 2nd token, %j to get the 3rd token, and %k to get all remaining tokens after the 3rd.
For file names that contain spaces, you need to quote the filenames with double quotes.  In order to use double quotes in this manner, you also need to use the usebackq option, otherwise the double quotes will be interpreted as defining a literal string to parse.

    %i is explicitly declared in the for statement and the %j and %k are implicitly declared via the tokens= option.  You can specify up to 26 tokens via the tokens= line, provided it does not cause an attempt to declare a variable higher than the letter 'z' or 'Z'.
    Remember, FOR variables are single-letter, case sensitive, global, and you can't have more than 52 total active at any one time.
    You can also use the FOR /F parsing logic on an immediate string, by making the file-set between the parenthesis a quoted string, using single quote characters.  It will be treated as a single line of input from a file and parsed.

    Finally, you can use the FOR /F command to parse the output of a command.  You do this by making the file-set between the parenthesis a back quoted string.  It will be treated as a command  line, which is passed to a child CMD.EXE and the output is captured into memory and parsed as if it was a file.  So the following
    example:

      FOR /F "usebackq delims==" %i IN (`set`) DO @echo %i

    would enumerate the environment variable names in the current  environment.

In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

    %~i         - expands %I removing any surrounding quotes (")
    %~fi        - expands %I to a fully qualified path name
    %~di        - expands %I to a drive letter only
    %~pi        - expands %I to a path only
    %~ni        - expands %I to a file name only
    %~xi        - expands %I to a file extension only
    %~si        - expanded path contains short names only
    %~ai        - expands %I to file attributes of file
    %~ti        - expands %I to date/time of file
    %~zi        - expands %I to size of file
    %~$PATH:I   - searches the directories listed in the PATH
                   environment variable and expands %I to the
                   fully qualified name of the first one found.
                   If the environment variable name is not
                   defined or the file is not found by the
                   search, then this modifier expands to the
                   empty string

The modifiers can be combined to get compound results:

    %~dpI       - expands %I to a drive letter and path only
    %~nxI       - expands %I to a file name and extension only
    %~fsI       - expands %I to a full path name with short names only
    %~dp$PATH:I - searches the directories listed in the PATH
                   environment variable for %I and expands to the
                   drive letter and path of the first one found.
    %~ftzaI     - expands %I to a DIR like output line

In the above examples %I and PATH can be replaced by other valid
values.  The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.


e.g.
for /r %%i in (*.doc) do (ren "%%i" "%%~ni(add)~%%xi")

2014年5月14日星期三

Latex 基础(2)之常用宏包、文类

常用文类的用途和特点
book 书籍、论文 默认有左右页区分处理,章起右页
report 商业、科技和试验报告 默认无左右页区分处理,章起新页
article 短文、评论、学术论文 无左右页区分处理,无章设置
beamer 幻灯片
ctex 提供的中文文类
ctexbook ctexrep ctexart
\usepackage{ctex} 或者ctexcap

常用宏包
amsmath 多种公式环境和数学命令
amssymb 数学符号生成命令
array 数组和表格制作
booktabs绘制水平表格线
calc 四则运算
caption 插图和表格标题格式
ctex 中文字体
ctexcap中文字体和标题
fancyhdr页眉页脚设置
fancyvrb抄录格式设置
geometry版本尺寸设置
graphicx插图设置
hyperref创建超文本链接和PDF书签
ifthen条件判断
longtable制作跨页表格
multicol多栏排版
ntheorem定理设置
paralist多种列表环境
tabularx自动设置表格的列宽
titlesec章节标题格式设置
titletoc目录格式设置
xcolor颜色处理

2014年5月10日星期六

latex基础(1) 之Latex命令

Latex命令
作用范围
1、声明形式,将作用于命令之后的所有相关内容,e.g.\bfseries
2、参数形式,作用于参数,e.g.\textsl{Asia}
3、组合形式,e.g. {\bfseries Asia}
4、环境形式

\newcommand{新命令}[参数数量][默认值]{定义内容}
\newcommand*{新命令}[参数数量][默认值]{定义内容}%不能含有换段命令或空行
e.g. \newcommand{\A}{\bfseries #1}
参数数量,可选参数,用于指定该新命令所具有参数的个数,可以是0-9之一,默认为0,即该命令没有参数;
默认值,可选参数,用于认定第一个参数的默认值,如果在新定义命令中给出默认值,则表示该新命令的第一个参数是可选参数。新命令中最多只能有一个可选参数,并且必须是第一个参数。
定义内容,对新命令所要执行的排版任务进行认定,其中涉及某个参数时用符号#n表示。
\newcommand 是个声明形式的命令,通常放在导言里。
e.g.
\newcommand{mycmdC}[2]{$#1_1,#1_2,\dots,#1_#2$}
\mycmdC{x}{n} %x1,x2,...,xn

\newcommand*{\B}{\bfseries #1}
带星号的形式,其中同之处在于使用它定义新命令时,命令中的各种参数不能含有换段命令\par或空行

Latex 图形 画图

\setlength{\unitlength}{长度}
\begin{picture}(width,height)
plot....
\end{picture}

确定图形元素的坐标系的位置
\put(x,y){图形元素}
\multiput(x,y)(Δx,Δy){个数}{图形元素}
e.g.
\multiput(3,4)(1,2){3}{图形元素}
在(3,4)(4,6)(5,8)画同样的图形

基本绘图命令
\line(Δx,Δy){length}
Δx,Δy 只能取0,±1,...,±6,且不能有公因子,斜线长度不能小于3.5mm
\vector(Δx,Δy){length}
\thinlines
\thcklines
\linethickness{thickness}

\circle{diameter}%圆周,直径不超过40pt
\circle*{diameter} %实心圆,直径不超过15pt

boxes:无线,有线,虚线
\makebox(width,height)[position]{text}
\framebox(width,height)[position]{text}
\dashbox{虚线长度}(width,height)[position]{text}
position:t,b,l,r,s(strctch,竖直方向居中,水平伸展充满例子),tl,tr,bl,br
\makebox是没框的盒子,使用最多的情况是把它的宽度和高度都取为0,成为一个点,利用位置参数容易确定文本的相对关系

\put(x,y){文本}
但更常用的是
\put(x,y){\makebox(0,0)[位置]{文本}}

竖直文本
\shortstack[位置]{一列文本}
e.g.
\shortstack[l(r)]{这是\\左对准\\堆叠文字}

\bezier{点数}(x1,y1)(x2,y2)(x3,y3)
\qbezier{}()()()

Latex作图 笔记

EPS: Encapsulated Post Scripts
%% boundingbox 0 0 200 100 1bp=0.35mm

\includegraphics[para]{pic name.jpg}
para:
外形参数:height,totalheight,width,scale,angle,origin,bb(EPS的boundingbox)
裁切参数:viewport,trim
bool para: keepaspecttatio,clip,draft
例:\includegraphics[wieth=\textwidth-20mm]{pic.jpg}

参数的统一设置:
\setkeys{Gin}{width=0.8\textwidth,height=35mm}

插图搜索
\graphcspath{{path1}{path2}{d:/mypic/png}}

任意对象的旋转和缩放
\rotatebox[para]{angle}{obj}
obj:text,pic,table,formular,any Latex obj
para:origin 对象的旋转点,
x,y 以对象基准点为坐标原点,给出旋转点的坐标,
units 单位
e.g. \rotatebox{90}{text...}

缩放
\scalebox{水平缩放系数}[垂直系数]{对象}
系数为负,表示反转
e.g. \scalebox{5}[1]{缩}

mirror
\reflectbox{obj}

imagemagick
图形处理软件--图形格式转换
www.imagemagick.org
convert pic_in pic_out wildcard supported

CTex自带图形格式转换工具
bmeps option pic_in pic_out.pex
pic_in :png,jpeg,tiff
option -c colorful

图文绕排
package:picinpar
3 ways: window,figwindow,tabwindow
e.g.
\begin{window}[rows,position,{encircled obj},{title}]
encircling text...
\end{window}
rows,position(l,c,r),obj(pic,table,text)

wallpaper
package:wallpaper
e.g.
\TileSquareWallPaper{layout no.}{pic}
\ThisTileSquareWallPaper{layout no.}{pic}%只对当前页有效

图形处理package overpic
需要用到graphicx epic
\usepackage[options]{overpic}
options percent,permil,abs
图形处理环境
\begin{overpic}[para]{背景图形名}
\前影图文命令
\end{overpic}