您的位置:首页 > 编程语言

LaTeX一些用法实例(并列图片 & 并列表格 & 算法代码示例 & 页眉太长 & 下划线,等)

2019-01-22 09:37 6274 查看
版权声明:转载请注明出处。 https://blog.csdn.net/sinich__eveen/article/details/86561883

目录

横向并列两个图片

竖向并列多个图片

并列两个表格

输入下划线,双下划线,波浪线,删除线,斜删除线

算法伪代码

LaTeX页眉显示:Title Suppressed Due to Excessive Length

更改页边距

标题中强制换行

横向并列两个图片

[code]\begin{figure}

\begin{minipage}{0.49\linewidth}

  \centering

  \includegraphics[width=6.5cm]{Simulation_Figures/Fig1_eps}

  \caption{The average outage probability versus $\gamma$}

  \label{Fig1}

\end{minipage}

\begin{minipage}{0.49\linewidth}

  \centering

  \includegraphics[width=6.5cm]{Simulation_Figures/Fig2_eps}

  \caption{Resource allocation among CSBSs for different algorithms}

  \label{Fig2}

  \end{minipage}

\end{figure}

其中【0.49\linewidth】控制双栏中每一栏的宽度

指定图片的大小【\includegraphics[width=4cm, height=3cm]{xxx.eps}】

 

显示效果:

 

竖向并列多个图片

[code]\begin{figure}

\centering

\subfigure[During the day]

{

\label{Fig8a}

\begin{minipage}[b]{0.5\textwidth}

\includegraphics[width=3.0in,height=3.0in]{Simulation_figures/Fig8a_pdf}

\end{minipage}

}

\subfigure[At night]

{

\label{Fig8a}

\begin{minipage}[b]{0.5\textwidth}

\includegraphics[width=3.0in,height=3.0in]{Simulation_figures/Fig8b_pdf}

\end{minipage}

}

\caption{Tidal effect} \label{Fig8}

\end{figure}

显示效果:

 

并列两个表格

[code]\begin{table}

\begin{minipage}{0.5\linewidth}

\center

\caption{CQET}

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

\hline

{SN} &  {Channel ID} & {Channel Quality}  \\

\hline

1 & $N$ & $Q_1^i$  \\

2 & $N-1$ & $Q_2^i$  \\

3 & $N-2$ & $Q_3^i$  \\

\dots & \dots & \dots  \\

$K_i$ & $N-K_i+1$ & $Q_{K_i}^i$  \\

\hline

\end{tabular}

\label{CQET}

\end{minipage}

\begin{minipage}{0.5\linewidth}

\center

\caption{SIT}

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

\hline

{Parameters} &  {Description}\\

\hline

$N_D^i$ & No. of total required channels\\

$N_{Init}^i$ & No. of initial service channels\\

$N_N^i$ & No. of still needed channels\\

$N_A^i$ & No. of available channels\\

$N_S^i$ & No. of current serving channels\\

$K_i$ & No. of current serving users\\

$PL_A^i$ & $N_D^i/N_S^i$\\

$PL_B^i$ & $N_D^i/K_i$\\

\hline

\end{tabular}

\label{SIT}

\end{minipage}

\end{table}

显示效果:

 

输入下划线,双下划线,波浪线,删除线,斜删除线

[code]\usepackage{ulem}

....

\uline{我是一个兵}  下划线

\uuline{我是一个兵}  双下划线

\uwave{我是一个兵} 波浪线

\sout{我是一个兵} 删除线

\xout{我是一个兵} 斜删除线

 

算法伪代码

宏包

[code]\usepackage{algorithmic}

\usepackage{algorithm}

 

代码实例:

[code]\begin{algorithm}[!t]

\caption{Fairness-based Distributed Resource Allocation Algorithm}

\begin{algorithmic}[1]

\STATE Let ${\cal G} = \left\{ {1,2, \ldots ,{\rm{G}}} \right\}$ denotes the set of CSBSs involved in the algorithm.

\FOR{all CSBSs within ${\cal G}$}

    \IF{CSBS $i$ $N_S^i=0, N_A^i=1, K_i \ne 0$}

        \STATE Select the first rank channel in the CQET of CSBS $i$

        \STATE Update CQET and SIT for the CSBS in ${\cal G}$

    \ELSE

        \STATE Select the CSBS $i = argmax[PL_A^i]$

        \IF{There are multiple CSBSs with the same $PL_A^i$}

            \STATE Select the CSBS $i = argmax[PL_B^i]$

            \IF{There are multiple CSBSs with the same $PL_B^i$}

                \STATE Select the CSBS $i = argmax[Q_1^i]$

                \STATE Select the first rank channel in the CQET of CSBS $i$

                \STATE Update CQET and SIT for the CSBS in ${\cal G}$

            \ELSE

                \STATE Select the first rank channel in the CQET of CSBS $i$

                \STATE Update CQET and SIT for the CSBS in ${\cal G}$

            \ENDIF

        \ELSE

            \STATE Select the first rank channel in the CQET of CSBS $i$

            \STATE Update CQET and SIT for the CSBS in ${\cal G}$

        \ENDIF

    \ENDIF

\ENDFOR

\STATE \textbf{output}: Channel allocation results $\left\{ {\tau _{i,k,n}^*} \right\}$.

\end{algorithmic}

\label{FDRA}

\end{algorithm}

显示效果:

 

 

LaTeX页眉显示:Title Suppressed Due to Excessive Length

例如:

 

解决方案:

用相应的【\authorrunning{}】和【\titlerunning{}】生成短一点的作者列表和标题。

 

代码实例:

 

 

更改页边距

[code]\usepackage{geometry}

\geometry{left=4.5cm,right=4.5cm,top=2.3cm,bottom=2.3cm}

 

 

标题中强制换行

[code]\caption{short text \protect\\ long text}

【\\】是脆弱命令,需要保护,必须在其前面加上【\protect】

 

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: