华华的OCTOPRESS BLOG

我是华华,这是我的OCTOPRESS博客

0111

| Comments

记录点latex的学习心得,最近写PPT,终于狠下心来用tex来写,不知道做ppt的时候会不会被老板痛批,不过做出来的PDF还是挺PP的,以前总是写一点就觉得很难放弃,继续使用powerpoint,这次装了office2007,可能很多东西都不会支持,所以干脆用PDF算了。

写点tex的学习心得,beamer还是比较简单的,找个模版套套就差不多了。主要是烦在插图上面花去了不少的时间。

frame{}写一页PPT

frametitle{}PPT标题

插图:

usepackage{subfloat}

begin{figure}
  centering
  subfloat[第一个小图形]{%
    label{fig:subfig1}
    includegraphics{hello.eps}}
  subfloat[第二个小图形。如果标题很长的话,它会自动换行,并且采用一种~hang 模式
,这个~caption 就是这样的例子。]{%
    label{fig:subfig2}
    includegraphics{hello.eps}}
  caption{包含子图形的大图形。}
  label{fig:big1}
end{figure}

figure环境中直接插入4幅图,即四个includegr…命令,每幅图大小设置略小于半文本宽度就行了。

newenvironment{figurehere}
  {def@captype{figure}}
  {}
makeatother

renewcommand{figurename}{FIG.}

裁剪PDF文件,去除图像周围不需要的空白。“裁剪页面”-> “删除白边距”即可。

 

beamer是常用的幻灯片工具。但是pdflatex命令似乎不支持eps图片,必需用pdf格式。
下面的步骤其实是说明了如何把任意图片转换为pdf格式。

a. 把要插入的图片打印为pdf格式(在acrobat中,可以先选择一个区域,然后执行
print的时候会只打印该区域)
b. 用acrobat professional打开该pdf图片,选择Document -> Crop Pages -> Remove
white margins去掉多余的白边。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  这个对于pdf图片中上面有很多空白很管用,
不然插入到beamer里图要么很小,要么没法显示

c. 这时就可以用includegraphics{aaa.pdf}了。

两表格

begin{figure}[htb]
  begin{minipage}[b]{0.5textwidth}
  centering
    begin{tabular}{|c|c|c|c|} hline
      Day & Data1 & Data2 & Data3\ hlinehline
      Monday    & 1.6 & 1.6 & 1.6 \
      Tuesday   & 1.3 & 1.6& 1.6 \
      Wednesday & 1.2& 1.6& 1.6 \
      Thursday  & 1.5 & 1.6& 1.6\
      Friday    & 1.9& 1.6& 1.6 \ hline
    end{tabular}

    caption{This is a  Table1}

    label{table:by1}
  end{minipage}%
  begin{minipage}[b]{0.5textwidth}
    centering
    begin{tabular}{|c|c|c|c|} hline
      Day & Data4 & Data5 & Data6\ hlinehline
      Monday    & 1.6 & 1.6 & 1.6 \
      Tuesday   & 1.3 & 1.6 & 1.6 \
      Wednesday & 1.2 & 1.6 & 1.6 \
      Thursday  & 1.5 & 1.6 & 1.6\
      Friday    & 1.9 & 1.6 & 1.6\ hline
    end{tabular}

    caption{This is a  Table2}

    label{table:by2}
  end{minipage}
end{figure}

表格与图

begin{figure}[htb]
  begin{minipage}[b]{0.5textwidth}
    centering
    includegraphics[width=0.5textwidth]{cf1.eps}
    caption{This is a Figure}
    label{fig:by:fig}
  end{minipage}%
  begin{minipage}[b]{0.5textwidth}
  vspace{-12em}
    centering
    begin{tabular}{|c|c|c|c|} hline
      Day & Data4 & Data5 & Data6\ hlinehline
      Monday    & 1.6 & 1.6 & 1.6 \
      Tuesday   & 1.3 & 1.6 & 1.6 \
      Wednesday & 1.2 & 1.6 & 1.6 \
      Thursday  & 1.5 & 1.6 & 1.6\
      Friday    & 1.9 & 1.6 & 1.6\ hline
    end{tabular}
    caption{This is a  Table}
    label{table:by:table}
  end{minipage}
end{figure}

两图

begin{figure}[htb]
  begin{minipage}[b]{0.5textwidth}
    centering
    includegraphics[width=0.6textwidth]{cf1.eps}
    caption{This is a Figure1}
    label{fig:by:fig1}
  end{minipage}%
  begin{minipage}[b]{0.5textwidth}
     centering
    includegraphics[width=0.6textwidth]{cf2.eps}
    caption{This is a Figure2}
    label{fig:by:fig2}
  end{minipage}
end{figure}

怎样使表格中的文字垂直居中

法1:
usepackage{array}
begin{tabular}{|c|m{3em}|m{3em}|}
    hline
    Month & 1,2,3,4 (A,B,C) & 5,6,7,8 (E,F,G)\hline
end{tabular}

法2:
usepackage{multirow}
begin{tabular}{|c|c|c|}
    hline
    multirow{2}{*}{Month} & 1,2,3,4 & 5,6,7,8 \
    & (A,B,C) & (E,F,G)\hline
end{tabular}

如果表格里的内容太长,超出页面宽度

begin{tabular}{l@{hspace{4ex}}l}
    LaTeX & 编译会生成.dvi文件用来预览\
    CCT & LaTeX & 用来编译中文。除了.dvi外,会生成ctextemp*的临时文件。可能
要编译两次\
    PDFLaTeX & 优点是生成可以复制的中文pdf(参见ref{cha:Copy
Problem},p.pageref{cha:Copy Problem})。可以编译中英文,不生成dvi文件,直接
生成pdf。
end{tabular*}

要自动换行就要指定列宽度。用p{width},或array宏包里的m{width}。

documentclass{article}
usepackage{array}
begin{document}
begin{tabular}{|*{3}{>{hfil}p{3cm}|}}
hline
This is only a test & This is another test & This is the last test\
hline
This is a very & & \
long sentence & &\ hline
end{tabular}
end{document}

此法中,文字如果超出列宽就会折行,而不会居中。这时就应分行写。

若总共有N列数据,选中前面N-1列,右键选“设置单元格格式”->自定义->G/通用格式

把"G/通用格式"改成"G/通用格式 &"确定即可

很多都是这次遇到的问题,希望下次不要再遇到了,不过问题一个个解决的时候真的觉得很爽,呵呵,发现自己又学到了不少的东西,最幸运的是找到了邓老师的书,但是PS格式的,还不能转成PDF,有空研究一下,那样用PDF打印出来就好了。

觉得有问题就是要主动去解决,然后把它写下来,过一段时间再去看看自己做了什么以后发现非常有成就感,也许人生在于这样的积累过和,我也我也该多记点东西了,不能光看,俗话说,好及筋不如烂笔头啊

Comments