Latex論文排版技巧再總結

Latex論文排版技巧再總結
發表於711 天前 ⁄ 科研 ⁄ 評論數 17 ⁄ 被圍觀 4,746 次+
這兩天在準備CIVR的Camera Ready Paper,用到Latex排版,雖然已經用了好多次,但是還是遇到了好多問題,然後網上好多技巧,再次記錄一下,以後用起來方便。

Congratulations on having your paper accepted for publication in the ACM International Conference on Image and Video Retrieval (CIVR 2010) to be held 5-7 July in Xi’an, China. 
 

1、Q:幾個作者同時共享機構地址,怎麼搞?

A:拿ACM的模版爲例,

Yes, and we suggest you do the following...

Insert this piece of coding just before the

\begin{document}

like so... 

%
\def\sharedaffiliation{%
\end{tabular}
\begin{tabular}{c}}
%
\begin{document}

and then adjust your particular 'author block' like so (example shown for 3 authors)...

\title{Alternate {\ttlit ACM} SIG Proceedings Paper in LaTeX
Format\titlenote{(Produces...}}

\numberofauthors{3}
% Three authors sharing the same affiliation.
    \author{
      \alignauthor Ben King\\
      \email{[email protected]}
%
      \alignauthor Georgia Tobin\\
      \email{[email protected]}
%
      \alignauthor Gerald Murray\\
      \email{[email protected]}
%
      \sharedaffiliation
      \affaddr{Department of Electrical Engineering and Computer Science }  \\
      \affaddr{University of California, Berkeley }   \\
      \affaddr{Berkeley, CA 94720-1776 }
          }
%
\maketitle

When compiled/previewed/rendered, this is the effect:

 

2、Latex如何正確輸入引號?

答:Tab鍵上方(1鍵左邊)的那個鍵,按兩下,輸入··,然後輸入兩個單引號'', 就是左右雙引號了。單引號同理啊。

3、如何使得雙欄文檔保持底部對齊?特別是參考文獻

在LATEX 標準文檔類中使用twocolumn 選項產生雙欄格式文檔的時候,如果一頁的內容不足以排滿頁
面時, LATEX 的結果是先排滿左欄,然後再排版右欄。這樣就造成了兩欄的長度不相等,底部不齊。很多
時候我們不希望這種排版結果。
這個問題只有在用標準文檔類的twocolumn 模式的時候纔會遇到,使用multicol 宏包就可以避免這個
問題(參見問題36 )。但是multicol 宏包也有一些缺點,例如不允許單欄的浮動對象(參見問題56 )。
要使標準文檔類的twocolumn 模式下也能做到雙欄底部對齊,可以通過手工調整分欄的位置。在
twocolumn 模式下\newpage 命令使LATEX 開始在新的一欄上排版,如果單前欄是左欄,就換到右欄上開始
排版。在合適的地方使用\newpage 命令可以使得雙欄底部對齊(注意,不能用\clearpage 命令,這個命
令會開始在新的一頁上排版,而不管當前在哪一欄上)。幾乎沒有人願意使用這種方法,不僅因爲它需要
你手工計算需要插入命令的位置,每次改動文檔都有可能需要變動\newpage 命令的位置,而且對於一些自
動生成的文檔內容(例如參考文獻和索引),要插入\newpage 命令十分困難。
°ushend 宏包通過修改LATEX 核心定義來解決這個問題。使用它提供的\flushend 命令可以使得雙欄底
部對齊,而\raggedend 命令則取消底部對齊。\flushend 命令會在宏包裝入的時候自動運行。°ushend 宏
包只對文檔最後一頁有效,也就是說所有中間的強制換頁,或者章節的自動換頁導致的雙欄底部不齊現象
都無法解決。
balance 宏包是另外一個更好的方法。它比balance 更加完善,而且對整個文檔的任何位置都有
效。balance 宏包提供了\balance 命令來打開雙欄底部對齊機制, \nobalance 命令來關閉這個機制。和
°ushend 宏包不同,它在裝入的時候缺省不打開對齊機制,因此需要在文檔中加入\balance 命令來啓用底
部對齊。
在使用這些宏包的時候需要注意,單欄的浮動對象有可能破壞這些宏包的對齊機制。這種時候需要手
工調整浮動對象的位置來改善排版效果。這也是multicol 宏包不支持單欄浮動對象的原因之一。

4、Latex怎麼對算法進行排版?

排版可能需要的包:

\usepackage{algorithm}               //format of the algorithm

\usepackage{algorithmic}             //format of the algorithm

\usepackage{multirow}                //multirow for format of table

\usepackage{amsmath}

\usepackage{xcolor}

\DeclareMathOperator*{\argmin}{argmin}         //argmin或argmax公式的排版

\renewcommand{\algorithmicrequire}{\textbf{Input:}}   //Use Input in the format of Algorithm

\renewcommand{\algorithmicensure}{\textbf{Output:}}  //UseOutput in the format of Algorithm

排版圖片可能需要的包:

\usepackage{graphics}

\usepackage{graphicx}

\usepackage{epsfig}

算法的排版舉例:

\begin{algorithm}[htb]         %算法的開始

\caption{ Framework of ensemble learning for our system.}             %算法的標題

\label{alg:Framwork}                  %給算法一個標籤,這樣方便在文中對算法的引用

\begin{algorithmic}[1]                %不知[1]是幹嘛的?

\REQUIRE ~~\\                          %算法的輸入參數:Input

    The set of positive samples for current batch, $P_n$;\\

    The set of unlabelled samples for current batch, $U_n$;\\

    Ensemble of classifiers on former batches, $E_{n-1}$;

\ENSURE ~~\\                           %算法的輸出:Output

    Ensemble of classifiers on the current batch,  $E_n$;

\STATE Extracting the set of reliable negative and/or positive samples $T_n$ from $U_n$  with help of $P_n$; \label{code:fram:extract}      %算法的一個陳述,對應算法的一個步驟或公式之類的; \label{ code:fram:extract }對此行的標記,方便在文中引用算法的某個步驟

\STATE Training ensemble of classifiers $E$ on $T_n \cup P_n$, with help of data in former batches; \label{code:fram:trainbase}

\STATE $E_n=E_{n-1}\cup E$; \label{code:fram:add}

\STATE Classifying samples in $U_n-T_n$ by $E_n$; \label{code:fram:classify}

\STATE Deleting some weak classifiers in $E_n$ so as to keep the capacity of $E_n$; \label{code:fram:select}

\RETURN $E_n$;                %算法的返回值

\end{algorithmic}

\end{algorithm}

排版效果圖:

 

在文中對算法和算法的某個步驟的引用:Therefore, in step \ref{code:fram:extract} of algorithm \ref{alg:Framwork}, we extract $T_n$, a set of reliable negative samples

1、  For和While循環語句的排版舉例

(1)       排版效果圖

 

(2)       排版代碼

\begin{algorithm}[h]

    \caption{An example for format For \& While Loop in Algorithm}

    \begin{algorithmic}[1]

        \FOR{each $i\in [1,9]$}

            \STATE initialize a tree $T_{i}$ with only a leaf (the root);\\

            \STATE $T=T\bigcup T_{i};$\\

        \ENDFOR

        

        \FORALL {$c$ such that $c\in RecentMBatch(E_{n-1})$} \label{code:TrainBase:getc}

            \STATE  $T=T \cup PosSample(c)$; \label{code:TrainBase:pos}

        \ENDFOR;

        

        \FOR{$i=1$; $i<n$; $i++$ }

            \STATE $//$ Your source here;

        \ENDFOR

        

        \FOR{$i=1$ to $n$}

            \STATE $//$ Your source here;

        \ENDFOR

        

        \STATE  $//$ Reusing recent base classifiers. \label{code:recentStart}

        \WHILE {$(|E_n| \leq L_1 )and( D \neq \phi)$}

            \STATE  Selecting the most recent classifier $c_i$ from $D$;

            \STATE  $D=D-c_i$;

            \STATE  $E_n=E_n+c_i$;

        \ENDWHILE \label{code:recentEnd}

        

    \end{algorithmic}

\end{algorithm}

5、圖片或者表格的裏是有標記腳註的“1”和“2”了,但是頁面下沒有腳註……

答案:[一]    在tabular 環境中添加腳註,不能簡單地使用\footnote{……}。應該在要添加腳註的地方使用\footnotemark[n]標記,其中n表示腳註的編號; 在tabular環境外則用\footnotetext[n]{……}填入腳註內容,注意這裏的[n]應該與表格中的\footnotemark中的 [n]一一對應。
示例:

\begin{tabular}{|c|c|c|}
\hline
類型名稱&佔用空間&表示範圍\
\hline
real&6字節\footnotemark[3]&.9 \times 10^{-39} \sim 1.7 \times 10^{38}$\
\hline
single&4字節&.5 \times 10^{-45} \sim 3.4 \times 10^{38}$\
\hline
double&8字節&.0 \times 10^{-324} \sim 1.7 \times 10^{308}$\
\hline
extended&10字節&.4 \times 10^{-4932} \sim 1.1 \times 10^{4932}$\
\hline
\end{tabular}
\footnotetext[3]{在~Free Pascal~中,real~類型可以自動轉換成~single~或~double~類型,所以佔用的空間大小也不固定。}
[二]使用\footnotemark在表格中插入腳註符號,然後在表格外面使用\footnotetext命令寫入腳註文字。如果在表格中多次使用了\footnotemark,在表格外面需要使用\addtocounter和stepcounter命令爲每個腳註寫入文字。參考下面的代碼:Reference

 

begin{footnotesize}
\begin{table}[htbp]
\centering
\renewcommand{\baselinestretch}{1.5}
\fontsize{9pt}{9pt}\selectfont \caption{Test results}
\begin{tabular}{c @{} c  c  c  c @{} c @{} c @{} c }
\hlinewd{1.5pt}
Test No.     & Liner    & Target     & \multicolumn{2}{c}{Cumulative damage}  & Diameter of & Hit density around  & Ejection angle \\
             & angle    & distance   & \multicolumn{2}{c}{region (ellipse)}   & the dense   & the cumulative      & of fragment in \\
\cline{4-5}  & /degree  & /m         & Major axis    & Minor axis             & fragment    & damage region       & the focused    \\
             &          &            & /mm           & /mm                    & region/mm   & /(pieces/m$^{2}$)   & region/degree  \\
\hlinewd{0.75pt} 2001-6-5-1& 10& 1& 185& 150& 525& 1017(9100 in
the hole)\footnotemark & 9.5 \\
2001-6-5-2& 10& 2& 160& 155& 360& 1565\footnotemark &4.5 \\
2001-6-5-3& 20& 3& 150& 110& 210& 3443&4.0 \\
2001-6-6-1& 20& 5.25& 122& 70& 235& 3708&2.5 \\
2001-6-6-2& 30& 4& 96& 82& 290& 3633&4.1 \\
2001-6-6-3& 30& 6& 78& 47& 320& 3385&3.1 \\
\hlinewd{1.5pt}
\end{tabular}
\label{Tab:2.1}
\end{table}
\end{footnotesize}

\addtocounter{footnote}{-1} \footnotetext{Since the distance was
only 1m, almost all the fragments hit the target, so that the hit
density of that test in the cumulative damage region can be
estimated.} \stepcounter{footnote}\footnotetext{1565.}
  6、如何生成固定寬度的表格?

在LATEX 中生成固定寬度的表格有兩種方法,一種是通過擴展列之間的空隙,另一種是擴展某些指定
的列。
第一種方法通過tabular* 環境來實現。在tabular* 環境的第一個參數中指定表格的總寬度,然後在
表格的列格式參數中使用\extracolsep 命令來增加列之間的空隙。
\begin{tabular*}{5cm}{@{\extracolsep{\fill}}lllr}
\hline
1 & 2 & 3 & 4 \\
21 & 22 & 23 & 24 \\
\hline
\end{tabular*}

如圖:


這種方法的一個缺點是列之間如果加入分隔符,則列之間的空隙是放在下一列的左邊而不是在兩列之間平
均分配。我們來看上面的例子加入分隔符後的樣子
\begin{tabular*}{5cm}
{@{\extracolsep{\fill}}|l|l|l|r|}
\hline
1 & 2 & 3 & 4 \\
21 & 22 & 23 & 24 \\
\hline
\end{tabular*}

效果圖:


另一種方法可以通過使用tabular 環境的列格式參數之一ph寬度i 來指定相應列的固定寬度。這種方法
需要用戶手工計算分配每個列的具體寬度。另外,由於p 參數不能和其他控制對齊方式的參數同時作用在
一個列上,因此需要使用額外的方法來控制這些列的對齊方式(參見問題53 )。
tabularx 宏包提供了一個自動計算分配列寬度的表格環境tabularx 。這個環境的使用方法和tabular*
相同。不同之處在於它增加了一個X 參數。所有使用X 參數的列會平均分配多餘的空間,然後轉換爲p
參數來指定列的寬度。該宏包也提供了方法讓你可以指定如何轉換或者轉換爲其他的列參數。該宏包需要
array 宏包的支持。
ltxtable 宏包則結合了longtable 和tabularx 宏包的特點。但是它的用法有點複雜,請仔細閱讀它的文
檔。

7、關於論文最後參考文獻 兩欄對齊,長度一樣的問題?

答:\usepackage{balance}

拿ACM的論文模板爲例:

\bibliographystyle{abbrv}
\balance
\bibliography{sigproc}
====================

1、Latex排版工作室:http://blog.sina.com.cn/wangzhaoli11

2、冰河的博客:http://www.icyhe.com

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章