Latex 经常见到的问题和解决方法

Latex 经常见到的问题和解决方法

2017-04-10  22:05:48 

【资源下载】

1). Texlive 2021 下载地址:https://mirrors.sjtug.sjtu.edu.cn/ctan/systems/texlive/Images/ 

2). AweSome LaTex: https://github.com/egeerardyn/awesome-LaTeX 

3). TexMaker (Free cross-platform LaTeX editor since 2003 (Windows, MacOsX, Linux)):  https://www.xm1math.net/texmaker/ 

sudo apt-get update 

sudo apt --fix-broken install 

sudo apt install texmaker 

 

 

1. IEEE 模板添加 通信作者的时候,总是无法正常显示(脚注无法正常显示):

  因为 IEEE默认是屏蔽了这个功能,需要在编辑的 .tex 文件中,添加这么一句话:

  \IEEEoverridecommandlockouts 

  

 

  然后就是:

  

  生成的 pdf文件就是正常的了:

  

 


2. 参考文献引用过程中,经常遇到 & 符号的问题,例如:

 

@article{Wang2016Person,
  title={Person Re-Identification by Discriminative Selection in Video Ranking},
  author={Wang, Taiqing and Gong, Shaogang and Zhu, Xiatian and Wang, Shengjin},
  journal={IEEE Transactions on Pattern Analysis & Machine Intelligence},
  volume={38},
  number={12},
  pages={1-1},
  year={2016},
}

 

  这里面的 & 符号在latex 中是无法直接编译过去的,需要用转义字符 \& 或者直接将其删除

  另一个需要注意的地方是:latex调用 .bib 参考文献的时候,需要四个步骤: 

  ==>>  pdflatex, bibtex, pdflatex, pdflatex 

  这样子,才可以在生成的 pdf 文件中,得到正确的参考文献显示。

 

3. The Textlive in linux operation, you  can install textlive 2017 and texmaker from software center. 

$ sudo mount -a /path/to/your/textlive/ /home/wangxiao/textlive/ 
$ cd /home/wangxiao/textlive/ 
$ sudo ./install-tl -gui 

  

## seting the environment: 

sudo gedit ~/.bashrc

and add the following lines into your file. 

export MANPATH=${MANPATH}:/usr/local/texlive/2016/texmf-dist/doc/man
export INFOPATH=${INFOPATH}:/usr/local/texlive/2016/texmf-dist/doc/info
export PATH=${PATH}:/usr/local/texlive/2016/bin/x86_64-linux

 

 

Configure your texmaker according to above figures. 

 

 4. Latex 排版带有大括号 {} 公式的方法:

$$ f(x)=\left\{
\begin{aligned}
x & = & \cos(t) \\
y & = & \sin(t) \\
z & = & \frac xy
\end{aligned}
\right.
$$



$$ F^{HLLC}=\left\{
\begin{array}{rcl}
F_L       &      & {0      <      S_L}\\
F^*_L     &      & {S_L \leq 0 < S_M}\\
F^*_R     &      & {S_M \leq 0 < S_R}\\
F_R       &      & {S_R \leq 0}
\end{array} \right. $$


$$f(x)=
\begin{cases}
0& \text{x=0}\\
1& \text{x!=0}
\end{cases}$$
 

效果分别为:

5. 左对齐:

 方法1: \begin{flushleft}...\end{flushleft}

方法2(推荐,亲测好用):
\noindent 

6.  参考文献中 作者的名字,变为横线(参考文献 77):

这是因为:在 bib 文件中,引用了多篇同一个作者的文章,并且这些文献在 LaTeX 文件中,处于很接近的位置,就非常会可能出现上述的情况。

 

解决方法就是:把引用的文献位置做相应的调整。

然后再看这个参考文献,就变的正常额:

 

7. 多行公式的编辑:

\begin{flalign}
&~~~~\hat{x_t} = W {x_t}& \\
&~~~~f'_t = \delta (W_f x_t + b_f)& \\
&~~~~r_t = \delta (W_r x_t + b_r) \\
&~~~~c_t = f_t \odot c_{t-1} + (1-f_t) \odot \hat{x_t} \\
&~~~~h_t = r_t \odot g(c_t) + (1-r_t) \odot x_t
\end{flalign}

 

 

8. WinEdt 10.3 下载与激活:

WinEdt 10.3 注册激活
下载安装:http://www.winedt.com/download.html

选择WinEdt 10.3 (64-bit) [Build: 20180507] (winedt103-64.exe 9.2 MB)下载,安装。

安装完成后,运行WinEdt ,依次打开Help >> Register WinEdt… 在弹出的对话框里包含Name,Code,Date。对应填入以下信息:

Name:Cracker TeCHiScy
Code:1130140925535334280
Date:不用填
点击OK保存

参考
1、http://www.52pojie.cn/thread-595351-1-1.html
2、https://blog.csdn.net/icp_09002463/article/details/80268387
---------------------
作者:Agzs
来源:CSDN
原文:https://blog.csdn.net/code_segment/article/details/82348626
版权声明:本文为博主原创文章,转载请附上博文链接!

 

9. CTEX 添加 eps 图像,并且正常执行的姿势是:https://blog.csdn.net/garfielder007/article/details/51628604 

\usepackage{graphicx}

\usepackage{epstopdf}

如果是eps的图形, 编译过程是  latex, dvips, ps2pdf.  
为了能够让参考文献正常显示,标准操作流程是:latex, bibtex, latex, dvips, ps2pdf

如果是pdf jpg png图形, 编译过程是  pdflatex .
 
 
10. ! LaTeX Error: File `newtxmath.sty' not found.

  ! LaTeX Error: File `newtxmath.sty' not found.

 

  Type X to quit or <RETURN> to proceed,

  or enter new name. (Default extension: sty) 

 

 

我当时貌似是重新安装了一遍 LaTeX 才搞定这个问题的。

 

 

 

 

 

 

11. 参考文献的添加和使用:

 

添加宏包:\usepackage{natbib}
{
\small
\bibliographystyle{plain} 
\bibliography{reference} 
}
 
 
12. arg max 编辑:
\begin{equation}
\label{trajSelection}
\hat{T_i} = \mathop{\arg\max}_{T_i^j} \sum_{j=1}^{N} S(T_0, T^j_i). 
\end{equation}

 

13. 自定义图目录,表格目录:

reference:https://blog.csdn.net/hyluglare/article/details/88742396 

 

生成插图目录的命令:\listoffigures

可以自定义目录名:\renewcommand\listfigurename{插\ 图\ 目\ 录}

生成表格目录的命令:\listoftables

可以自定义目录名:\renewcommand\listtablename{表\ 格\ 目\ 录}

 

14. 调整文章中 超链接的颜色:

\usepackage[colorlinks, linkcolor=red,  anchorcolor=blue, citecolor=black]{hyperref}

 

15. LaTeX技巧421:LaTeX表格tabular背景色添加技巧 【Source

我们所用的宏包为colortbl,这个宏包可以设置表格中数据、文本、行、列、单元格前景和背景以及边框的颜色,从而得到彩色表格。同时需要 array 和 color 两个宏包的支持。 宏包提供了一组着色命令,经常用到是列着色命令,其格式为:

\columncolor[色系]{色名}[左伸出][右伸出]。

常用色系有三原色 rgb 灰度 gray  和四色cmyk三种;被预定义的色名有68个,详见 color 宏包介绍中所附的色标;左右伸出的长度单位可用 pt。

colortbl 的主要命令

\columncolor[颜色模型]{颜色}[左伸出长度][右伸出长度]在这里,\columncolor 和 \rowcolor 的参数是一样的,他们的共同语法是:

我们现在就来看个实例,这里头有些例子,包括:灰阶横条、部份字段着色、整个表格在着色背景及单一个表格内方框着色:

示例代码如下:

\documentclass[12pt]{article}

\usepackage{textcomp,booktabs}

\usepackage[usenames,dvipsnames]{color}

\usepackage{colortbl}

\definecolor{mygray}{gray}{.9}

\definecolor{mypink}{rgb}{.99,.91,.95}

\definecolor{mycyan}{cmyk}{.3,0,0,0}

\parindent=0pt

\parskip=3ex

\begin{document}

\centering

 

\section*{SPECIFIC HEATS (20 \textcelsius\ AND 1 ATM)}

\begin{tabular}{>{\sf }lll}    %

\toprule

& \multicolumn{2}{c}{\bf Specific Heats} \\

\cmidrule{2-3}

& $c$ (J/kg$\cdot$K) & $C$ (J/mol$\cdot$K) \\

\midrule

Aluminum    & 900 & 24.3 \\

\rowcolor{mygray}

Copper      & 385  & 24.4 \\

Gold       & 130  & 25.6 \\

\rowcolor{mygray}

Steel/Iron  & 450  & 25.0 \\

Lead       & 130  & 26.8 \\

\rowcolor{mygray}

Mercury     & 140 & 28.0 \\

Water       & 4190 & 75.4 \\

\rowcolor{mygray}

Ice ($-$10 \textcelsius) & 2100 & 38 \\

\bottomrule

\end{tabular}

 

\vspace{8ex} %

\section*{SPECIFIC HEATS (20 \textcelsius\ AND 1 ATM)}

\begin{tabular}{>{\columncolor{mypink}\sf }lll@{}}

\toprule

\rowcolor{white}

& \multicolumn{2}{c}{\bf Specific Heats} \\

\cmidrule{2-3}

\rowcolor{white}

& $c$ (J/kg$\cdot$K) & $C$ (J/mol$\cdot$K) \\

\midrule

Aluminum    & 900 & 24.3 \\

Copper      & 385  & 24.4 \\

Gold       & 130  & 25.6 \\

Steel/Iron  & 450  & 25.0 \\

Lead       & 130  & 26.8 \\

Mercury     & 140 & 28.0 \\

Water       & 4190 & 75.4 \\

Ice ($-$10 \textcelsius) & 2100 & 38 \\

\bottomrule

\end{tabular}

 

 

\section*{SPECIFIC HEATS (20 \textcelsius\ AND 1 ATM)}

\fboxsep=12pt

\colorbox{mypink}{

\begin{tabular}{@{}>{\sf }lll@{}}

\toprule

& \multicolumn{2}{c}{\bf Specific Heats} \\

\cmidrule{2-3}

& $c$ (J/kg$\cdot$K) & $C$ (J/mol$\cdot$K) \\

\midrule

Aluminum    & 900 & 24.3 \\

Copper      & 385  & 24.4 \\

Gold       & 130  & 25.6 \\

Steel/Iron  & 450  & 25.0 \\

Lead       & 130  & 26.8 \\

Mercury     & 140 & 28.0 \\

Water       & 4190 & 75.4 \\

Ice ($-$10 \textcelsius) & 2100 & 38 \\

\bottomrule

\end{tabular}}

 

\vspace{8ex} %

\section*{SPECIFIC HEATS (20 \textcelsius\ AND 1 ATM)}

\begin{tabular}{@{}>{\sf }lll@{}}

\toprule

& \multicolumn{2}{c}{\bf Specific Heats} \\

\cmidrule{2-3}

& $c$ (J/kg$\cdot$K) & $C$ (J/mol$\cdot$K) \\

\midrule

Aluminum    & 900 & 24.3 \\

Copper      & 385  & 24.4 \\

Gold       & 130  & 25.6 \\

Steel/Iron  & 450  & 25.0 \\

Lead       & 130  & 26.8 \\

Mercury     & 140 & 28.0 \\

Water       & \multicolumn{1}{>{\columncolor{mycyan}}l}{4190} & 75.4 \\

Ice ($-$10 \textcelsius) & 2100 & 38 \\

\bottomrule

\end{tabular}

 

 

\setlength{\extrarowheight}{2mm}

\begin{tabular}{|l|c|c|c|c|c|c|c|}

\hline

Sydney & OG4G &Thu Oct 10 &Mon Oct 21 or 28 &11 or 18 days &999\\

\rowcolor[gray]{0.5}

& &Thu Oct 17 &Mon Oct 21 or 28 & 4 or 11 days &999\\

&OG7A &Sun Oct 13 &Mon Oct 21 or 28 & 8 or 15 days &999\\

\rowcolor[gray]{0.5}

& &Sun Oct 20 &Mon Oct 28 & 8 days &999\\

\hline

\end{tabular}

 

 

\setlength{\extrarowheight}{2mm}

\setlength{\tabcolsep}{2mm}

\begin{tabular}{|l|%

>{\columncolor{yellow}}c|c|>{\columncolor{yellow}}c|c|%

>{\columncolor{red}\bfseries}c<{\textsc{GBP}}|}

\hline

\multicolumn{3}{>{\columncolor{red}}l}{\color{white}\textsf{LONDON}}

&\multicolumn{3}{>{\columncolor{red}}r}{\color{white}\textsf{Price}}

\\[1pt]

\hline

Sydney & OG4G &Thu Oct 10 &Mon Oct 21 or 28 &11 or 18 days &999\\

& &Thu Oct 17 &Mon Oct 21 or 28 & 4 or 11 days &999\\

& OG7A &Sun Oct 13 &Mon Oct 21 or 28 & 8 or 15 days &999\\

& &Sun Oct 20 &Mon Oct 28 & 8 days &999\\

\hline

\end{tabular}

 

 

\setlength{\arrayrulewidth}{2pt}

\arrayrulecolor{green}

\begin{tabular}{|l|c|r|}

\arrayrulecolor{black}\hline

United Kingdom & London & Thames\\

\arrayrulecolor{blue}\hline

France & Paris & Seine \\

\arrayrulecolor{black}\cline{1-1}

\arrayrulecolor{red}\cline{2-3}

Russia & Moscow & Moskva \\ \hline

\end{tabular}

\end{document}
View Code

 

16. Latex中如何设置字体颜色(三种方式)[Source]

1).直接使用定义好的颜色

\usepackage{color}

\textcolor{red/blue/green/black/white/cyan/magenta/yellow}{text}

其中textcolor{...}中包含的是系统定义好的颜色

 

2).组合red、green和blue的值合成我们想要的颜色

\usepackage{color}

\textcolor[rgb]{r,g,b}{text}

其中{r,g,b}代表red、green和blue三种颜色的组合,取值范围为[0-1]

\textcolor[RGB]{R,G,B}{text}

其中{R,G,B}代表red、green和blue三种颜色的组合,取值范围为[0-255]

 

3).定义一种颜色,直接调用

\usepackage{color}

\definecolor{ColorName}{rgb}{r,g,b}      这时r/g/b的定义域就在[0-1]。

\definecolor{ColorName}{RGB}{R,G,B},这时R/G/B的定义域就在[0-255]。

这里为颜色定义了名称ColorName,下面可以直接调用这个颜色方案

\textcolor{ColorName}{text}

 

17. Latex 表格中强制换行:[Source]

 基本操作如下:

  • 宏包:\usepackage{makecell}

  • 环境:tabular

  • 命令:\makecell[居中情况]{第1行内容 \\ 第2行内容 \\ 第3行内容 ...}

参数说明:

  • [c]是水平居中,[l]水平左居中,[r]水平右居中;

  • *[c]水平 + 垂直居中,*[l]垂直居中 + 水平左居中,*[r]垂直居中 + 水平右居中。

 

 

 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

   

 

 

posted @ 2017-04-10 22:07  AHU-WangXiao  阅读(11314)  评论(0编辑  收藏  举报