latex

Tips

  1. In order to get a paragraph break in LaTeX, leave a blank line.

  2. You can write one sentence per line.

  3. comment is % and is escape.

Format

  1. page margin

    1
    2
    3
    usepackage{geometry}
    geometry {papersize = {20cm,15cm}}
    geometry {left = 1cm ,right =2cm ,top =3cm, bottom =4cm}
    1. page header and footer
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    usepackage{fancyhdr}
    pagestyle{fancy}
    lhead{author}
    chead {date}
    rehad {...}
    lfoot{}
    cfoot{}
    rfoot{}
    renewcommand{headrulewidth}{0.4pt}
    renewcommand{headrulewidth}{textwidth}
    renewcommand{headrulewidth}{0pt}
    1. line space
    1
    2
    usepackage {setspace}
    onehalfspacing
    1. paragraph space
    1
    addtolength{parskip}{.4em}
    1. Emphsis
    1
    emph {text}
    1. Bold
    1
    textbf{text}

Fancy Text

  1. Numbered lists can be made with the following code:

    1
    2
    3
    4
    5
    begin{enumerate}
    item One thingdots
    item dots leads to another.
    end{enumerate}
    % If you want to have an un-numbered list with bullets, replace both instances of enumerate with itemize.
  2. Graphics

    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
    includegraphics{samplereport-graphic}
    % You should save the image file in the same folder as your LaTeX code.

    % However, I much prefer that graphics be encapsulated in a figure. Thus I would rather you use code like the following:

    begin{figure}[h]
    centering
    includegraphics[width=3in]{SampleReport-Graphic.pdf}
    caption{The caption of a figure should be a complete sentence.}
    label{SampleFigure}
    end{figure}

    %Figure across two columns
    大专栏  latexbegin{figure*}
    end{figure*}

    %Two figures layout side by side
    usepackage{subfig}
    usepackage{subcaption}
    usepackage{stfloats}

    begin{figure}[h]
    centering
    subfloat[caption1] {{ includergraphics[width=3.5cm]{Figure1.png} }}
    qquad
    subfloat[caption1] {{ includergraphics[width=3.5cm]{Figure2.png} }}
    caption{ General caption}
    label{}
    end{figure}
  3. Catalogue

    1
    2
    tableofcontents
    % After the maketitle
  1. Use Chinese

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    % set the char-set to utf-8
    % use ctex package,there are two method you can use
    % Method 1 note the ctex auto indent.
    usepackage{ctex}

    % Method 2
    document[UTF8]{ctexart}
    begin {document}
    你好!世界
    end {document}
  2. Reference

    • Method 1 : refer directly

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      begin{thebibliography}{1}
      bibitem{liu} 刘海洋. LaTeX 入门 [M]. 北京: 电子工业出版社, 2013.
      bibitem{hu} 胡伟. LaTeX 2e完全学习手册(第二版). 北京: 清华大学出版社, 2013.
      bibitem{label}
      end{thebibliography}

      {1}:是用来占位的,表示每条文献的编号宽度
      label:是文献引用时候的label引用的命令是 cite{label},在中文文档中, 参考文献引用时需要写到文字 的右上角, 需要对命令 cite{...} 重新定义(下面这句话放置在导言区, 即begin{document}之 前):
      newcommand{upcite}[1]{textsuperscript{textsuperscript{cite{#1}}}}
      重新定义的命令是 upcite{label}
    • Method 2 : batch refer with using bibtex

      • create bib file and input all the reference.

      • save the bib to the same folder with tex.

      • refer by cite{label}.

      • 1
        2
        bibliographystyle{plain}
        bibliyography{bibfileName}
> 文章中没有引用的参考文献,即使在建立bib数据库的时候使用了,在最后的Reference里面也不会出现,这也是为什么建议在阅读文献的时候就顺手建立bib数据库.

Article Kind

  1. article/ctexart

    1
    2
    3
    4
    5
    6
    % define 5 series to algin the article
    section {}
    subsection {}
    subsubsection {}
    paragraph {}
    subparagraph {}
  2. book/ctexbook

    1
    part{}
  3. report/ctexrep

    1
    chapter {}
上一篇:如何创建一个输出matplotlib图形的函数?


下一篇:通过改变像素来缩小图片