Latex常用功能记录

图片插入

根据构建命令不同需要不同格式的图片

PdfLaTeX可以用png jpg pdf等

本文介绍LaTeX + dvips + ps2pdf,图片格式必须是eps或ps

\usepackage{epsfig}

\epsfig{figure=f1.eps,scale=1}

算法插入

常用算法格式的插入

宏包algorithm2e:

\usepackage[linesnumbered,ruled]{algorithm2e} %%宏包进行配置
\IncMargin{1em} 
\begin{algorithm}

    \SetAlgoNoLine
    \SetKwInOut{Input}{\textbf{input}}
    \SetKwInOut{Output}{\textbf{output}}

    \Input{
        The request for $content$\;\\}
    \Output{
        $Pkt = out$\;\\}
    \BlankLine

    my line one \;
    and this is my second line\;
    \Repeat
        {\text{overflow}}
        {add a triple $additon$\;
            \For {pkt $\leq$ $threshold$}{
                $pkt \leftarrow threshold$
            }
        }
        
    \eIf{understand}{
		go to next section\;
		current section becomes this one\;
		}{
		go back to the beginning of current section\;
		}
    \caption{Learning algorithm2e\label{al3}}
\end{algorithm}
\DecMargin{1em}

实例

宏包algorithmalgorithmic:

\usepackage{algorithm, algorithmic}
\begin{algorithm}
	\renewcommand{\algorithmicrequire}{\textbf{Input:}}
	\renewcommand{\algorithmicensure}{\textbf{Output:}}
	\caption{Learning Macro algorithm $\&$ algorithmic}
	\label{alg:1}
	\begin{algorithmic}[1]
		\REQUIRE a request for $content$
		\ENSURE $Pkt$
		\STATE My Line One 
		\STATE And this is the second
		\FOR {$ pkt \in D_{p}$}
		\IF{$content < threshold$}
		\STATE $swap(threshold, content)$
		\ENDIF 
		\STATE Update $pkt$ based on threshold
		\ENDFOR
		\STATE \textbf{return} $pkt$
	\end{algorithmic}  
\end{algorithm}

分栏布局

注意multicols默认先填满左栏,但是在最后一页会默认左右均衡填充

\begin{multicols}{2}
    ...
\end{multicols}

左对齐:

\begin{flushleft}
    ...
\end{flushleft}

居中:

\begin{center}
    ...
\end{center}

右对齐:

\begin{flushright}
    ...
\end{flushright}

两端对齐:

\justifying
    ...
\justifying

文本格式

换行: 

//    %%自动换行,无法用于段落开头
~~\\  %%段落开头自动换行

猜你喜欢

转载自blog.csdn.net/Athrun_misou/article/details/83893302
今日推荐