论文排版和作图
Latex使用
1. 特殊符號
1.1. 斷字符?(hyphenation)?
latex使用了處理斷字的算法去自動的找斷字的地方,而且latex會調整單詞間距,使得文章看起來不會顯得疏密不一致。大多數情況下,這些算法都工作得很好。但是因為斷字的算法是根據某種規則來處理單詞的斷字,而不是依照人工事先標注的字典,所以,它仍然會出問題。或是在不該斷的地方斷開了,又或者是斷開的地方太多了等等。在latex下可以通過調整參數和指定斷字點來處理這些問題。
| \hyphenpenalty=5000 \tolerance=1000=5000 \tolerance=1000 |
可以把這兩個參數的調整加到tex文件里。hyphenpenalty的意思比較顯而易見,這個值越大斷字出現的就越少。tolerance越大,換行就會越少,也就是說,latex會把本該斷開放到下一行的單詞,整個兒的留在當前行。調這兩個值就可以得到不一樣的排版,有可能可以解決斷字太多的問題。
如果遇到了斷開的地方不對的情況,也可以手動來指定一個單詞應該怎么斷。
| <span style="color:#cc33cc">\hyphenation{hy-phen-a-tion}</span> |
這個命令告訴latex,hyphenation只能從標有短橫線(-)的地方斷開。
或者:
For the words?small,?space, and?results?to get hyphenated as?s-mall,?s-pace, and?result-s, somebody or something must have reset two of TeX's fundamental hyphenation-related parameters, viz.,?\lefthyphenmin?and?\righthyphenmin. For an English-language setting, the default values of these parameters are
\lefthyphenmin=2and
\righthyphenmin=3Something in your document must have managed to set both parameters to?1?(or possibly?0). Be sure to either delete the commands that modify these two parameters or insert the two instructions above in your document (to reset the parameter values to their respective default values).
1.2. 井號 # 符號
文本中直接使用#會報錯,可以參考下面的用法:
\documentclass{article}\begin{document} Using \verb|\verb|: \verb|#| and using \verb|\texttt|: \texttt{\#} and then regular symbol using \verb|\#|: \#\end{document}2. 通過mathtype插入公式
注意:直接從mathtype中粘貼公式時,需要將公式兩邊的符號 $ $ 去掉
?
\begin{equation} \label{eq1} {L_{MSE}} = \frac{1}{N}\sum\limits_i^N {\left\| {{P_i} - {G_i}} \right\|_2^2} \end{equation}3. 插入并排圖片
begin{figure} \centering \subcaptionbox{Subcaption A}{\includegraphics[width=0.20\textwidth]{example-image-a}}% \hfill \subcaptionbox{Subcaption B}{\includegraphics[width=0.20\textwidth]{example-image-b}}% \hfill \subcaptionbox{Subcaption C}{\includegraphics[width=0.20\textwidth]{example-image-c}}% \hfill \subcaptionbox{Subcaption D}{\includegraphics[width=0.20\textwidth]{example-image}}% \caption{Caption} \end{figure}另一個例子,并排圖片,每個圖片有一個figure名和caption
\begin{figure} \begin{minipage}[t]{0.5\textwidth}\centering\includegraphics[scale=0.2]{cpn.pdf}\caption{adefajfadsf dafafa \label{fig:1}}\end{minipage}\qquad\begin{minipage}[t]{0.5\textwidth}\centering\includegraphics[scale=0.2]{cpn.pdf}\caption{6bbadf fwefwea \label{fig:2}}\end{minipage} \end{figure}4.?各種引用
4.1.? 文獻引用reference.bib報錯
常見問題1. 文獻序號顯示問號?異常,比如不能正確顯示?Tom et e.l. [1] 而是顯示的是Tom et e.l. [?],這是可以檢查如下:
檢查mytex.blg文件,查看錯誤日志,如果發現報錯‘缺少***.bst文件’,則是因為所使用的latex包里面沒有相對應的可用文件,可以自己添加一個,比如IEEEtran.bst,同時把其他可能需要的文件如IEEEabrv.bib也下載拷貝到當前的排版latex中,刪除bbl重新編譯。
常見問題2. 需要在正文中至少引用一條文獻,就不會報錯了。另外,有時我們是在原有的論文模板上進行的,這些不僅需要引用至少一條文獻,而且需要刪除已經存在的.bbl文件,然后重新編譯!!
另外補充一點,如果在編寫引用文獻的過程中出錯了,在修改完重新編譯之前,也需要刪除bbl文件。
如果更新了\cite{}以及bib文件,發現生成的pdf的reference中還包含應該被刪除的條目,正文中被刪除的引用序號被跳過,這是也應該刪除bbl文件,重新編譯。
4.2 文獻引用的格式問題
4.2.1 文獻引用顯示的格式[1,2,3]和[1-3]
如果包含了 \usepackage{cite} 包的話,那么在一個地方引用多個文件如果序號是相連的,則會變成[1-3]的形式,如果把這個包去掉,則生成的格式是[1,2,3]。
4.2.2 文獻引用缺少年份
查看bib文件中對應文獻的year={}之前的逗號是否遺漏。
4.2.3?同時引用多個文獻時,只能顯示第一文獻,其他文獻顯示的都是問號??
把例如?? \cite{Chen2017Cascaded, Papandreou2017Towards, He2017Mask, Fang2017RMPE}中逗號之后的空格去掉,不留空格就能顯示正確。
4.2.4?bibtex的格式要求說明
詳情見如下鏈接:
https://wenku.baidu.com/view/0f2096643968011ca300916d.html
其中的說明例如:
@article 條目為期刊或雜志上的一篇文章。
? ? 不可少域author, title, journal, year.?
? ? 可省略域volume, number, pages, month, note. @book條目為有確定出版社的書籍。
? ? 不可少域author或editor, title, publisher, year.?
? ? 可省略域volume或number, series, address, edition, month, note. @booklet條目為印制的有封皮的作品,但沒有出版社或贊助機構的名稱。
? ? ? 不可少域title.?
? ? 可省略域author, howpublished, address, month, year, note. @conference與下面的@inproceedings相同。
@inbook 條目為一本書的一部分(章,節或某些頁)。
? ? 不可少域author或editor, title, chapter和/或pages, publisher,year. ? ? 可省略域volume或number, series, type, address, edition, month, note. @incollection條目為一本書中有自己題目的一部分。
? ? 不可少域author, title, booktitle, publisher, year.?
? ? 可省略域editor, volume或number, series, type, chapter, pages, address, edition, month, note.?
@inproceedings 條目為會議論文集中的一篇文章。
? ? 不可少域author, title, booktitle, year. ? ? 可省略域editor, volume或number, series, pages, address, month, organization, publisher, note.?
4.3 隱藏文章中交叉引用和文獻引用的超鏈接標志方框
在文章導入package的地方添加:
\hypersetup{hidelinks} ?% 隱藏文章中的鏈接跳轉標志框或者用下面代碼,這些包含超鏈接的文本周圍不會會出現彩色的方框,但是超鏈接文本會使用不同顏色的字體
\usepackage[colorlinks, ? ? ? ? ??linkcolor=red, ? ? ? ? ? ?anchorcolor=blue, ? ? ? ? ??citecolor=green ? ? ? ? ? ?]{hyperref}“colorlinks”的意思是將超鏈接以顏色來標識,而并非使用默認的方框來標識。
linkcolor, anchorcolor, citecolor分別表示用來標識link, anchor, cite等各種鏈接的顏色。
若正式的文檔中不想使用彩色的標識,但又希望具有超鏈接的功能,則將上例中的各種顏色換成“black”即可。
還比如,如果將論文中的citation和ref引用字體變成藍色,用下面設置即可
\usepackage{hyperref} \hypersetup{ colorlinks=true, linkcolor=blue, citecolor=blue }4.4 交叉引用標簽名使用段落,圖表的本身名,而不是自動編號的數字
把\ref{}改為\nameref{}即可
4.5?footnote引用報錯
報錯信息:
name{Hfootnote.1} has been referenced but does not exist, replaced by a fixe
解決辦法:一般這種情況是因為?you are not following the rule "load hyperref as the last package" and that something is redefining footnote.
5. Latex目錄中添加附錄,‘Appendix A.’
轉載自
You can easily achieve what you want using the?appendix?package. Here's a sample file that shows you how. The key is the?titletoc?option when calling the package. It takes whatever value you've defined in?\appendixname?and the default value is?Appendix.
\documentclass{report} \usepackage[titletoc]{appendix} \begin{document} \tableofcontents\chapter{Lorem ipsum} \section{Dolor sit amet} \begin{appendices}\chapter{Consectetur adipiscing elit}\chapter{Mauris euismod} \end{appendices} \end{document}The output looks like
6. 添加appendix
轉載自
The?\appendix?command changes the way sectional units are numbered. The?\appendix?command generates no text and does not affect the numbering of parts.
Thus, if you want your appendix to be set off with a section-like label you need something like
\begin{center}{\bf APPENDIX}\end{center}I have found the?\appendix?command to sometimes cause problems since?everything?which follows it is treated as part of the appendix, for example, a list of figures, which I generally want to place after an appendix is labeled "Appendix: List of Figures".
One can create a section labeled "APPENDIX" with distinctive numbering by using the?\section?command with suitably redefined commands for the?Counters. The following example generates a single "Appendix" with equations numbered A-1, A-2, ...
\renewcommand{\theequation}{A-\arabic{equation}}% redefine the command that creates the equation no.\setcounter{equation}{0} % reset counter \section*{APPENDIX} % use *-form to suppress numberingIf one had several appendices, appropriate numbering could be obtained by redefining the?\thesection?command and resetting the section counter in an analogous manner.
7. Latex中添加沒有編號的section標題
使用命令? \section*{Appendix A: ******},其中\senction*將不會添加序號
8. Latex多行公式的編寫
可以使用 array,用矩陣的形式排列一個個公式,并且把他們對齊
比如:
\begin{sequation} S_{ j }^{ * }\left( p \right) =\left\{?\begin{array}{lr}?G({ x, ?y ?| ?\sigma ?}_{ k }, ?r_{ 0 }), \quad 1 \le j \le K \\?G({x, y ?| ?\sigma ?}_{ p }, d_{ 0 }), \quad K+1 \le j ?\le K+P.\end{array}?\right.\label{eq1}\end{sequation}9. latex數學公式中的某些字符變成黑體
使用\usepackage{bm}包,然后在數學公式中用\bm{}包裹需要黑體的字符。
比如:
\begin{sequation}
?? ?Sd_{j}^{t}\left( p \right)=\left\{?
?? ?\begin{array}{lr}
?? ??? ?S_{j}^{t}\left( \bm{p} \right) -\alpha, \:\: S_{j}^{*}\left( p \right)>thre \\ ? ?% ?\hfill right align
?? ??? ?1-S_{j}^{t}\left( p \right)-\beta , \:\:\: else,?
?? ?\end{array}?
?? ?\right.
?? ?\label{eq2}\end{sequation}
另外,如果想在文本中加黑,也可以使用 bm,例如:COCO validation set and obtain \textbf{73.6\bm\%} ?AP
10. latex畫表格
控制表格內的字體大小
表格線的加粗,參見:latex表格線的加粗及合并兩行_蔣國寶的IT技術博客-CSDN博客_latex表格線加粗
\begin{table} ?\footnotesize\caption{Results on the validation subset.} ? ?\label{table1}\centering\begin{tabular}{llllllllll} ? % 這里面的豎線是小些字母L\toprule ? % 用來畫表格最上方的橫線Method ? ? ??? ? &Input ? ? ? ? ? &Stride ? ? ? ? ? ? & MS ? ? ? ? ? ? ? & AP ? ? ? ?\hspace{0.05cm} ? \vline ? \hspace{0.05cm} ? & Method ? ? ??? ? &Input ? ? ? ? ? &Stride ? ? ? ? ? ? & MS ? ? ? ? ? ? ? & AP ? \\ ? %\vline ? \Method ? ? ??? ? &Input ? ? ? ? ? &Stride ? ? ? ? ? ? & MS ? ? ? ? ? ? ? & AP ? ? ? ?\hspace{0.05cm} ? \vline ? \hspace{0.05cm} ? & Method ? ? ??? ? &Input ? ? ? ? ? &Stride ? ? ? ? ? ? & MS ? ? ? ? ? ? ? & AP ? \\ ? %\vline ? \\bottomrule ?% 用來畫表格最下方的橫線\end{tabular} \end{table} ?控制表格或者圖片插入的位置:
[!ht] 應該是這樣的:
首先,!表示無視美學規則,按下面的要求放置;
然后h t b p分別代表4中放置方式,優先級依次遞減。
h=here 放置在代碼中這個圖片出現的位置,也就是你想讓它出現的位置;
t = top 放在該頁頂端;
b = bottom 放在該頁底部;
p = page 另起一頁單獨放。
所以,你也可以自己定優先級,tbhp之類啥的
通過對表格進行整體縮放控制大小
使用\resizebox命令
\begin{table*}[!ht] \caption{Results on the MS-COCO 2017 validation set.}\smallskip\label{table1}\centering\resizebox{1.96\columnwidth}{!}{\smallskip\begin{tabular}{c|c|c|c|c|c|c|c|c|c|c|c} % 這里面的豎線是小些字母L {c|p{3.7cm}|c|c|c|c|c|p{3.2cm}|c|c|c|c} \toprule % % 還可以用\toprule[2pt] 手動改變表格邊界線條的粗細ID & \textbf{Method} &Input &Stride &${\cal FL}$ & \textbf{AP} &ID &\textbf{ Method} &Input &Stride &${\cal FL}$ & \textbf{AP} \\ % line 0\midrule 1 &CMU-Pose (6-stage CMU-Net) &368 &8 &N &56.0 &12 & 3-stage IMHN, w/ MST &384 &4 &Y &65.1 \\ % line 12&AE (4-stage Hourglass, + val data) &512 &4 &N & 59.7 &13& 4-stage IMHN &384 &4 &N & 64.5 \\ % line 23&Top-down$^{*}$ (8-stage Hourglass) &256 &4 &N & 66.9 &14& 4-stage IMHN &384 &4 &Y & 67.3 \\ % line 34 &Ours (3-stage CMU-Net) &368 &8 &N & 56.5 &15& 4-stage IMHN, + val data &384 &4 &Y & 72.3 \\ % line 5 5 &Ours (3-stage CMU-Net) &368 &8 &Y & 60.7 &16& 4-stage IMHN plus &512 &4 &Y & 69.1 \\ % line 5 6 &Ours (4-stage Hourglass) &512 &4 &N &60.0 &17 & 4-stage IMHN plus, + val data &512 &4 &Y & 74.1 \\ % line 47 &3-stage IMHN &384 &4 &N &61.5 &18& 4-stage IMHN, one scale &768 &4 &Y & 63.4 \\ % line 68 &3-stage IMHN &384 &4 &Y &65.8 &19& 4-stage IMHN plus, one scale &768 &4 &Y &65.9 \\ % line 79 &3-stage IMHN, w/o spatial attention &384 &4 &Y &64.6 &20 & PifPaf (ResNet-101), one scale &801 &8 &-- & 65.7 \\ % line 710 &3-stage IMHN, w/o channel attention &384 &4 &Y &65.4 &21& PersonLab$^{*}$, one scale &801 &8 &-- &61.2 \\ % 11 &3-stage IMHN, ${\cal FL}$ only for keypoint &384 &4 &Y &64.2 &22 & PersonLab$^{*}$, one scale &1401 &8 &-- &66.5 \\ %8 \bottomrule % 可以在未尾行(\bottomrule[2pt])加粗\end{tabular}} \end{table*}11. 一行插入兩個表
\begin{minipage}{\textwidth}\begin{minipage}[t]{0.48\textwidth}\centering\makeatletter\def\@captype{table}\makeatother\caption{table 1 the first}\scalebox{0.85}{ % 控制表格縮放\begin{tabular}{cccc} \toprule % 用來畫表格最上方的橫線\multicolumn{2}{c}{Part} \\\cmidrule(r){1-2}Name & Description & Size ($\mu$m) \\\midruleDendrite & Input terminal & $\sim$100 \\Axon & Output terminal & $\sim$10 \\Soma & Cell body & up to $10^6$ \\\bottomrule % 用來畫表格最下方的橫線\end{tabular}}\end{minipage} % 兩個表格之間不能添加空行,否則就會變成垂直方向的排列% \hspace{2cm} % 自己想出來的,控制兩個并列的表格間距 \begin{minipage}[t]{0.48\textwidth}\centering\makeatletter\def\@captype{table}\makeatother\caption{table 2 then}\scalebox{0.85}{\begin{tabular}{cccc} \toprule % 用來畫表格最上方的橫線\multicolumn{2}{c}{Part} \\\cmidrule(r){1-2}Name & Description & Size ($\mu$m) \\\midruleDendrite & Input terminal & $\sim$100 \\Axon & Output terminal & $\sim$10 \\Soma & Cell body & up to $10^6$ \\\bottomrule % 用來畫表格最下方的橫線\end{tabular}}\end{minipage} \end{minipage}12. 學會使用查看log文件,里面一般會有詳細的報錯信息!
13. 添加 pdf information
在\title{}命令之前添加以下信息
\pdfinfo{ /Title (Simple Pose: Rethinking and Improving a Bottom-up Approach for Multi-Person Pose Estimation) /Author (Jia Li, Wen Su, Zengfu Wang) }14. vscode latex workshop編譯中文論文綁定run button為xelatex -> bibtex -> xelatex*2
通過setting設置:?"latex-workshop.latex.recipe.default": "lastUsed", // 定義使用最后一個recipe
并且一定要保證編譯的tex文檔開頭沒有使用% !TeX program = xelatex魔法命令
畫圖
1. ppt畫出豎直線和水平線
按住shift鍵即可。
2. ppt作圖利用visio轉pdf插入latex,如何去除圖的多余邊距
在自定義功能區的主選項卡中找到開發工具,在顯示形狀表的下拉菜單中單擊頁。然后在Print properties 中將 PageLeftMargin,PageRightMargin,PageTopMargin,PageBottomMargin的值設置為0,然后關閉頁。最后在菜單欄中單擊設計,在大小下拉菜單中單擊適應繪圖,就會得到沒有頁邊距的Visio圖。其中后面兩步前后順序無所謂。
3. Mac上PPT作圖直接保存為pdf格式,禁止文本自動換行
默認文本框內的文字在保存為pdf時會自動換行,如下面左圖。點擊設置對象格式,文本選項,勾掉“形狀中的文字自動換行”,再次保存就為下面右圖了。
??
Markdown使用
插入圖片居中顯示并添加圖片標注:
<center> <img style="border-radius: 0.3125em; box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="這里輸入圖片地址"> <br> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">這里輸入題注</div> </center>
插入圖片左對齊顯示:
<img src="http://pic15.photophoto.cn/20100615/0006019058815826_b.jpg" height="330" width="495" align='left'>
控制顏色和字體等
markdown編輯器語法——文字顏色、大小、字體與背景色的設置_一步一個腳印-CSDN博客_markdown 顏色
淺紅色文字:<font color="#dd0000">淺紅色文字:</font><br />?
深紅色文字:<font color="#660000">深紅色文字</font><br />?
淺綠色文字:<font color="#00dd00">淺綠色文字</font><br />?
深綠色文字:<font color="#006600">深綠色文字</font><br />?
淺藍色文字:<font color="#0000dd">淺藍色文字</font><br />?
深藍色文字:<font color="#000066">深藍色文字</font><br />?
淺黃色文字:<font color="#dddd00">淺黃色文字</font><br />?
深黃色文字:<font color="#666600">深黃色文字</font><br />?
淺青色文字:<font color="#00dddd">淺青色文字</font><br />?
深青色文字:<font color="#006666">深青色文字</font><br />?
淺紫色文字:<font color="#dd00dd">淺紫色文字</font><br />?
深紫色文字:<font color="#660066">深紫色文字</font><br />?
如果添加顏色字體而不想換行,把后面的<br /> 去掉。
總結
- 上一篇: 图片预加载学习(二):有序加载之图片切换
- 下一篇: Excel行高与像素值,列宽与像素值之间