标题:LaTeX 学习笔记
最近又要用到latex,之前写过一篇latex相关的笔记文章,但是我感觉还不够,所以在此补充。
本文旨在:
1)对 LaTeX 文档中的各个元素(如\usepackage)进行介绍;
2)其他。(查漏补缺)
一开始搜 latex small title ,second title 。。。有点尬。
实际上是:latex subtitle
这样就行。\large
搜索关键字:latex table of contents dotfill
加上这两行就行。
\usepackage{tocloft}
\renewcommand\cftsecleader{\cftdotfill{\cftdotsep}}
效果:
搜索:;latex long string
(我的关键词有点。。。弱)
主要靠这个:
\usepackage{seqsplit}
关键词:latex url line break
(也有点挫。。)
解决方案:
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
\usepackage{xurl}
二者缺一不可,用了之后感觉还挺好看的。。。链接变好看了。。。(终于知道别人文章里面的框框是怎么来的了)
这个latex社区还是强,什么都有,还很详细。
关键词:latex margins
(不是很准确。凑合…)
我的设定是:
\usepackage[margin=1.2in]{geometry}
还是很方便的,不喜欢太复杂的方案。一切从简。
关键词:latex enumerate distance
方案1:
\vspace{-0.2cm}
+ \itemsep0em
\vspace{-0.2cm}
\begin{enumerate}
\itemsep0em
\item 跨站脚本(Cross-site Scripting);
\item 不恰当身份验证(Improper Authentication);
\item 信息披露(Information Disclosure);
\item 提权(Privilege Escalation);
\item SQL注入(SQL Injection);
\item 代码注入(Code Injection);
\item 服务器端请求伪造 (Server-side Request Forgery);
\item 不安全直接对象引用 (Insecure Direct Object Reference);
\item 不恰当访问控制(Improper Access Control);
\item 跨站请求伪造(Cross-site Request Forgery)。
\end{enumerate}
方案2:
前提是:\usepackage{enumitem} 先添加这个包,
然后在\begin{enumerate}后面加上[noitemsep]
就行。如下:
\begin{enumerate}[noitemsep]
…
\end{enumerate}
我更喜欢方案1,因为灵活。
\begin{quote}
\#include \\
\#include \\
asmlinkage long sys\_deheng\_test(int arg0)\{
\hspace{0.7cm} printk("I am syscall");
\hspace{0.7cm} printk("syscall arg \%d",arg0);
\hspace{0.7cm} return ((long)arg0);\\
\}\\
asmlinkage long sys\_hello(void)\{\\
printk("hello my kernel worldn");\\
return 0;\\
\}\\
asmlinkage long strcpy\_deheng(char*dest, const char* src)\\
\{\\
int i=0;\\
while(src[i]!=0)\\
dest[i]=src[i++];\\
dest[i]=0;\\
return i;\\
\}\\
\end{quote}
要注意的地方:
1)要缩进,上一行就不能打\\
,应该用空行代替。
2)\quad
和 \hspace{0.7cm}
都可以。
参考:
关键词:latex print \n
%----------------------------------------------------------------
\usepackage{lmodern}
\newcommand*{\escape}[1]{\texttt{\textbackslash#1}}
%----------------------------------------------------------------
\hspace{0.7cm} printk("I am a syscall.\escape{n}");
\hspace{0.7cm} printk("Syscall arg is: \%d\escape{n}",arg0);
参考:
此外,使用\textbackslash
也可以输出\
。
原代码:
#include
#include
#include
int main(int argc,char **argv)
{
printf("\nTest sys_deheng(a self-defined system call) now:\n\n");
syscall(337,1337);
printf("\n");
syscall(338);
// char *dest=NULL,*src="HelloDeheng";
char *dest=NULL,*src=argv[1];
printf("\n\nBefore copy:%s\n",dest);
dest=(char*)malloc(strlen(src)+1);
syscall(339,dest,src);
printf("After copy:%s\n",dest);
return 0;
}
在复制这段代码后,在TeXstudio中按下:crtl+shift+v
,即可得到如下自动转换的格式,太强了!!!
(还是很厉害的,简单有效。)
\begin{table}[!ht]
\centering
\sffamily \begin{tabularx}{1\textwidth}{>{\centering\arraybackslash}m{3cm}|>{\centering\arraybackslash}m{11cm}}
% {p{3cm}<{\centering}p{11cm}<{\centering}}
% p{2cm}<{\centering}p{1.5cm}<{\centering}
\hline\hline\noalign{\smallskip}
\textbf{搜索关键词}&\textbf{搜索结果}\\
\noalign{\smallskip} \hline \noalign{\smallskip}
Linux内核漏洞 & 直至第四页才看到相关新闻:"Linux内核曝出'脏奶牛'漏洞:已存在9年,数百万用户受影响" \url{https://www.ithome.com/html/it/266554.htm} \\
\noalign{\smallskip} \hline \noalign{\smallskip}
Linux内核经典漏洞 & 第二页最后一个搜索结果显示上述新闻 \\
\noalign{\smallskip} \hline \noalign{\smallskip}
Linux内核漏洞 提权 & 第二页第一个为:"linux本地内核提权漏洞 Dirty COW 成因分析" \url{https://blog.csdn.net/softgmx/article/details/79772772} 在该链接中,CSDN社区又提供了一大片有关脏牛漏洞的描述,如复现过程,调试过程等等 \\
\noalign{\smallskip} \hline \noalign{\smallskip}
linux kernel 4.4.6 vulnerability & 在第一页能发现:"Dirty COW (CVE-2016-5195)" \url{https://dirtycow.ninja/} 等四个和dirty cow相关的搜索结果 \\
\noalign{\smallskip} \hline \noalign{\smallskip}
linux kernel vulnerability & 第一页仅含"Dirty COW" \url{https://en.wikipedia.org/wiki/Dirty\_COW}一个网页 \\
\hline\hline
\end{tabularx}\normalfont
\caption{搜索关键词及其结果} \label{tab-search}
\end{table}
\begin{table}[h]
\centering
\sffamily \begin{tabularx}{1\textwidth}{>{\centering\arraybackslash}m{3cm}|>{\centering\arraybackslash}m{3.7cm}|>{\centering\arraybackslash}m{3.7cm}}
\hline
~ & \textbf{Helpful} & \textbf{Harmful} \\
\hline
\textbf{Internal origin} (organization) & Item 1 ~\textbullet~ Item 2 ~\textbullet~ Item 3 ~\textbullet~ Item 4 ~\textbullet~ Item 5 ~\textbullet~ Item 6 ~\textbullet~ Item 7 ~\textbullet~ Item 8 ~\textbullet~ Item 9 & Item 1 ~\textbullet~ Item 2 ~\textbullet~ Item 3 ~\textbullet~ Item 4 ~\textbullet~ Item 5 ~\textbullet~ Item 6 ~\textbullet~ Item 7 ~\textbullet~ Item 8 ~\textbullet~ Item 9 \\
\hline
\textbf{External origin} (environment) & Item 1 ~\textbullet~ Item 2 ~\textbullet~ Item 3 ~\textbullet~ Item 4 ~\textbullet~ Item 5 ~\textbullet~ Item 6 ~\textbullet~ Item 7 ~\textbullet~ Item 8 ~\textbullet~ Item 9 & Item 1 ~\textbullet~ Item 2 ~\textbullet~ Item 3 ~\textbullet~ Item 4 ~\textbullet~ Item 5 ~\textbullet~ Item 6 ~\textbullet~ Item 7 ~\textbullet~ Item 8 ~\textbullet~ Item 9 \\
\hline
\end{tabularx} \normalfont
\caption{SWOT matrix}
\label{tab:swot-matrix}
\end{table}
关键词:
latex text box
\vspace{0.5cm}\noindent\fbox{%
\parbox{\textwidth}{%
adduser deheng
su deheng
cd usr
./poc\_null
}}\vspace{0.5cm}