latex初学者的经验

1.一定要及时换行,要不然latex是不会替你自动换行缩进的,相反如果我第几十个字来换一次那么它就会替我自动缩进下换行。

2.关于中文首段缩进问题可用 usepackage{indentfirst} + setlength{parindent}{2em} 来实现

3.setcounter{section}{-1}可使章节从0序号开始

4.usepackage[top=25mm,left=25mm,right=20mm,bottom=20mm]{geometry}可以来定制文档格式

5.documentclass[a4paper,12pt]{article}可以用来指定纸张和通用字体大小

6.usepackage[dvips]{graphicx}

    begin{figure}[!h]  %只有加了[!h]才能在文字下方显示
    centering
    includegraphics[width=16cm]{1}
    renewcommand{figurename}{图}
    label{figure1}
    caption{}
    end{figure}

可以被用来插入esp图片,图片可用gimp转换得到,如果使用参考引用的话figure1不能为中文

7.正文中的参考文献序号可由 $,^mathrm{cite{id}}$来达到上标的目的,另外id不能为中文

8.renewcommand{figurename}{图}

  renewcommand{contentsname}{目录}
  renewcommand{abstractname}{摘要}

  可以将英文格式改为中文。

9.如果使用usepackage{listings} + begin{lstlisting} end{lstlisting}包含代码出错时不妨试试begin{lstlisting}[extendedchars=true,language=C++]或begin{lstlisting}[extendedchars=false,language=C++]

如果还是有些中文注释出问题的话不妨试一下lstset{basicstyle=ttfamily,escapechar=`}来设置逃逸字符,然后使用

  `出问题的中文注释`来解决问题。

10.关于产生要写学号姓名那一类的封面

可以使用begin{tabular}{l@{}c p{10cm}}来实现!

11.使用vspace{1cm}来产生一个中文空格



关于重新编译内核后VirtualBox不能使用的问题

      编译完内核后进入linux3.0内核后,习惯性的打开virtualbox,然后突然发现virtualbox提示错误,然后又出现一个对话框,上面写着:

Nevertheless, there is no shortage of changes, such as the auto grouping of processes within a session, which has caused a lot of commotion in the Linux online world as it is expected to considerably increase the reaction speed of the desktop environment under certain ambient conditions

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

'/etc/init.d/vboxdrv setup'

as root. Users of Ubuntu, Fedora or Mandriva should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.

      然后就开始了我的一下午的google,发现网上大都是说使用

/etc/init.d/vboxdrv setup进行重新编译,我试了之后发现仍提示
Failed, trying without DKMS ... failed!
Recompiling VirtualBox kernel modules:
Look at /var/log/vbox-install.log to find out what went wrong ... failed!

好吧,再google,又有了新的答案了,说是让使用

sudo apt-get install dkms

来安装dkms再编译,汗我还不太懂啥叫dkms,但人家说装就装呗,装着装着我就感觉不对劲,怎么净是些linux2.6.32的kernel-headers啊,我的内核可是才编译的linux-3.0的,果然,我装上dkms后再使用

/etc/init.d/vboxdrv setup

依然得到的是那个错误。

       再次google时意外的发现另一种方法:

sudo apt-get install linux-headers-$(uname -r)

去安装头文件,然后进入/usr/src/vboxhost-4.1.8/中去编译,但是不知道是我的源有问题还是内核太新了,sudo apt-get 安装失败了根本找不到linux-headers-3.0.0。

        没办法只有自己硺磨了,不管怎么说先进入/usr/src/vboxhost-4.1.8再说吧

cd /usr/src/vboxhost-4.1.8

然后编译一下试试

make

得到如下信息:

*** Building 'vboxdrv' module ***
make[1]: Entering directory `/usr/share/virtualbox/src/vboxhost/vboxdrv'
Makefile:172: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again。 停止。
make[1]: Leaving directory `/usr/share/virtualbox/src/vboxhost/vboxdrv'
make: *** [all] 错误 2


苦思冥想之后斗胆试了一下

sudo make KERN_DIR=/usr/src/linux-3.0

结果惊奇的发现似乎可以了,然后理所当然

sudo make install

理所当然的得到了如下信息

make[1]: Entering directory `/usr/share/virtualbox/src/vboxhost/vboxdrv'
Makefile:172: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again。 停止。
make[1]: Leaving directory `/usr/share/virtualbox/src/vboxhost/vboxdrv'
make: *** [install] 错误 2


于是再加个Shell变量试试

sudo make install KERN_DIR=/usr/src/linux-3.0

成功了。

       然后再执行

sudo /etc/init.d/vboxdrv setup(KERN_DIR=/usr/src/linux-3.0)

得到如下信息

Error! Your kernel headers for kernel 3.0.0 cannot be found at
/lib/modules/3.0.0/build or /lib/modules/3.0.0/source.

Failed, trying without DKMS ... failed!
Recompiling VirtualBox kernel modules:
Look at /var/log/vbox-install.log to find out what went wrong ... failed!


于是进入/lib/modules/3.0.0/然后发现source这个软链接被链接到我编译的目下去了,而我又把那个目录给移到别处了,难怪会出错了,把原目录移回来再执行,OK,一切正常了。

      再次打开virtualbox,发现又有新的错误

Failed to load unit 'HGCM' (VERR_INVALID_PARAMETER)

google后发现好像跟saved state有关,于是右键virtualbox中的windowsxp系统,选择discard saved state.

       再次重新virtualbox,OK终于进入了xp!大功告成!

ps:貌似比以前更快了哈,不知道是不是错觉!