Latex common commands (for personal use)

1. Insert a single picture

\begin{
    
    figure}[H]
\centering
\includegraphics[scale=0.3]{
    
    fig/picture.png}
\caption{
    
    图片说明}
\label{
    
    fig:1}
\end{
    
    figure}

2. Insert multiple pictures

\begin{
    
    figure}[H]
\centering
\subfigure[]
 {
    
    
   \centering
   \includegraphics[scale=0.3]{
    
    fig/picture1.png}
 }
    \subfigure[]
    {
    
    
      \centering
      \includegraphics[scale=0.2]{
    
    fig/picture2.png}
    }
\caption{
    
    图片说明,(a)第一张图片说明,(b)第二章图片说明}
\label{
    
    fig:1}
\end{
    
    figure}

3. For formulas without serial numbers, and including newline operations, you need to add \begin{gathered}

$$\begin{
    
    gathered}
u(0,y,t) = 6u_ry(1-y) ,\quad v(0,y,t) = 0;\\
u(x,0,t) = u(x,1,t) = v(x,0,t) = v(x,1,t) = 0;\\
T(x,0,t) = 1 ,\quad T(x,1,t) = 0 , \quad T(0,y,t) = 1-y;
\end{
    
    gathered}
$$ 

4. Tables with frames around them

\begin{
    
    table}[!ht]
    \centering
    \begin{
    
    tabular}{
    
    |l|l|l|l|}
    \hline
        ~ & $\Delta T = 5t^*$ & $\Delta T = 10t^*$ & 相对误差 \\ \hline
        $\left\langle\overline{
    
    N u}_{
    
    \mathrm{
    
    b}, \mathrm{
    
    t}}\right\rangle$ & 2.479 & 2.479 & $0\%$ \\ \hline
        $u_{
    
    max}$ & 4.3453 & 4.3447 & $0.014\%$ \\ \hline
    \end{
    
    tabular}
\end{
    
    table}

5. Common three-line forms

\begin{
    
    table}[!ht]
    \centering
    \begin{
    
    tabular}{
    
    cccc cc}%{
    
    |l|l|l|l|}
    \hline\hline\noalign{
    
    \smallskip}
        ~ & $\Delta T = 5t^*$ & $\Delta T = 10t^*$ & 相对误差 \\ \hline
        $\left\langle\overline{
    
    N u}_{
    
    \mathrm{
    
    b}, \mathrm{
    
    t}}\right\rangle$ & 2.479 & 2.479 & $0\%$ \\ \hline
        $u_{
    
    max}$ & 4.3453 & 4.3447 & $0.014\%$ \\ \hline
    \end{
    
    tabular}
\end{
    
    table}

The difference between them is whether \begin{tabular} is followed by ccc or |1|1|
and for the topmost line, it should be set to double lines, the command is \hline\hline\noalign{\smallskip}

6. Add code setting command

%----------------------------------添加代码控制--------------------------------%
\usepackage{
    
    listings}
\lstset{
    
    
    basicstyle=\footnotesize\ttfamily,
    numbers=left,
    numberstyle=\tiny,
    numbersep=5pt,
    tabsize=4,
    extendedchars=true,
    breaklines=true,
    keywordstyle=\color{
    
    blue}\bfseries,
    numberstyle=\color{
    
    purple},
    commentstyle=\color[rgb]{
    
    0, 0.4, 0}\bfseries,
    stringstyle=\color{
    
    violet}\ttfamily\bfseries,
    rulesepcolor=\color{
    
    red!20!green!20!blue!20},
    showspaces=false,
    showtabs=false,
    frame=shadowbox,
    framexrightmargin=5pt,
    framexbottommargin=4pt,
    showstringspaces=false,
    escapeinside=`', %逃逸字符(1左面的键),用于显示中文
}
\renewcommand{
    
    \lstlistingname}{
    
    CODE}
\lstloadlanguages{
    
    % Check Dokumentation for further languages, page 12
    Pascal, C++, Java, Ruby, Python, Matlab, R, Haskell
}
%------------------------------------------------------------------------------%

7. How to cite code in the text

\begin{
    
    lstlisting}
print("hello world")
\end{
    
    lstlisting}

Guess you like

Origin blog.csdn.net/ambu1230/article/details/129476169