美文网首页
Latex 写作技巧

Latex 写作技巧

作者: 乘瓠散人 | 来源:发表于2020-06-22 10:48 被阅读0次

    作图需要的包:

    \usepackage{graphicx}
    \usepackage{subfigure}
    \usepackage{caption}
    
    • 左侧展示Table, 右侧展示Figure
    \begin{table}[t]
        \begin{minipage}[c]{0.45\linewidth}
            \centering
            \caption{Performance of different NNs}
            \label{nn_res}
            \begin{tabular}{llll}
                \toprule
                Metrics & 32s & 16s & 8s \\
                \midrule
                Accuracy & 89.58 & 90.30 & 90.37 \\
                \bottomrule
            \end{tabular}
        \end{minipage} \hfill
        \begin{minipage}[c]{0.45\linewidth}
            \centering
            \includegraphics[width=0.9\linewidth]{pics/lr}
            \captionof{figure}{Comparison of the influence of different learning rate strategies.}
            \label{lr}
        \end{minipage}
    \end{table}
    
    • 左侧展示Figure, 右侧展示caption
    \begin{figure}[t]
        \centering
        \begin{minipage}[c]{0.32\textwidth}
            \centering
            \includegraphics[width=\textwidth,height=0.1\textheight]{figs/tree_fig1_v4.pdf}
        \end{minipage}
        \quad
        \begin{minipage}[c]{0.58\textwidth}
            \caption{A tree.}
            \label{tree}
        \end{minipage}
        \vspace{-14pt}
    \end{figure}
    
    • 多张图并排展示
    \begin{figure}[t]
        \centering
        \subfigure[Loss]{
            \begin{minipage}[t]{0.3\linewidth}
                \centering
                \includegraphics[width=2.2in]{pics/32loss.pdf}
                %上下并排两张图
                %\includegraphics[width=2.2in]{pics/32acc.pdf}
                %\caption{fig1}
            \end{minipage}%
        }%
        \subfigure[Metrics of the train set]{
            \begin{minipage}[t]{0.3\linewidth}
                \centering
                \includegraphics[width=2.2in]{pics/32train_metric.pdf}
                %\caption{fig2}
            \end{minipage}%
        }%
        \subfigure[Metrics of the validation set]{
            \begin{minipage}[t]{0.3\linewidth}
                \centering
                \includegraphics[width=2.2in]{pics/32val_metric.pdf}
                %\caption{fig2}
            \end{minipage}
        }%
        \centering
        \caption{Loss and performance of NNs along with iterations}
        \label{loss}
    \end{figure}
    
    • 多张表格并排显示 (单栏模板)
    \begin{table}[t]
        \caption{xxx}
        \label{xxx}
        \centering
        \begin{minipage}[t]{0.48\linewidth}
            \resizebox{\textwidth}{!}{
                \begin{tabular}{ccccc}
                    ...
            \end{tabular} }
        \end{minipage}
    \hfill
        \begin{minipage}[t]{0.48\linewidth}
            \resizebox{\textwidth}{!}{
                \begin{tabular}{ccccc}
                    ...
            \end{tabular} }
        \end{minipage}
    \end{table}
    
    • 多张表格并列显示 (双栏模板)
    \usepackage{subcaption}
    
    \begin{table}[t]
        \begin{subtable}[t]{\columnwidth}
            \centering
            \begin{tabular}{ccccc}
                ...
            \end{tabular}
            \caption{}
        \end{subtable}
    \vfill
        \begin{subtable}[t]{\columnwidth}
            \centering
            \begin{tabular}{ccccc}
                ...
            \end{tabular}
            \caption{}
        \end{subtable}
    \caption{xxx}
    \label{xxx}
    \end{table}
    
    • 绘制拆分表格
    \usepackage{booktabs}
    \usepackage{multirow}
    \begin{table}[htbp]
        \centering
        \caption{Comparison of XXX.}
        \label{toy}
        \resizebox{\columnwidth}{!}{
        \begin{tabular}{lllll}
            \toprule
            \multirow{2}{*}{} & \multicolumn{2}{c}{CNN} & \multicolumn{2}{c}{RNN} \\
            \cmidrule(r){2-3} \cmidrule(r){4-5}
            & Precision & Recall & Precision & Recall \\
            \midrule
            One & 65\% & 66\% & 65\% & 66\% \\
            \midrule
            Two & 65\% & 66\% & 65\% & 66\% \\
            \bottomrule
        \end{tabular} }
    \end{table}
    
    
    • 绘制跨行跨列表格
    \renewcommand{\arraystretch}{1.2}   % 设置表格行间距
    \begin{table}[t]
        \centering
        \resizebox{0.9\columnwidth}{!}{
            \begin{tabular}{l|cc|c|cc|c}
                \hline
                \multirow{2}{*}{} & \multicolumn{3}{c}{F1} & \multicolumn{3}{|c}{Recall} \\
                \cline{2-4} \cline{5-7}
                & A & B & \textbf{Avg.} & A & B& \textbf{Avg.} \\
                \hline
                Mothod & 1 & 2 & \textbf{1.5} & 2 & 3 &\textbf{2.5}  
                \hline
            \end{tabular} }
        \caption{xxx.}
        \label{toy}
    \end{table}
    
    • 设置字体背景高亮
    \usepackage{xcolor}
    \definecolor{mypink}{RGB}{255, 204, 204}
    \definecolor{myyellow}{RGB}{255,255,153}
    \definecolor{myblue}{RGB}{204,204,255}
    
    \begin{table}[t]
        \caption{Constituents.}
        \label{example}
        \centering
        \resizebox{\textwidth}{!}{
        \begin{tabular}{l|l}
            \toprule
            fruits & 1st \\
            \midrule
            An apple and bananas . &\colorbox{myblue}{An} \colorbox{myblue}{apple}  \\
            \bottomrule
        \end{tabular} }
    \end{table}
    
    
    • 多行公式对齐
    % 方法1:equation环境
    公式编号默认居中,如果你的编号没居中,而是在最后单独占了一行,
    那是因为你的公式每行太长了,编号想居中都没位置。
    \begin{equation}
    \label{xxx}
    \begin{aligned}
    ...
    \end{aligned}
    \end{equation}
    % 方法2:align环境
    \begin{align}
    ...
    \end{align}
    % 方法3:eqnarray环境
    \begin{eqnarray}
    ...
    \end{eqnarray}
    

    相关文章

      网友评论

          本文标题:Latex 写作技巧

          本文链接:https://www.haomeiwen.com/subject/odfxfktx.html