缩减代码片段嵌入到table的单元格中的上下空白填充.

2019-09-20 10:58发布

代码片段如下: ``` %!TeX encoding = UTF-8 %!TeX program = xelatex \documentclass{article} \usepackage{listi...

代码片段如下: ``` %!TeX encoding = UTF-8 %!TeX program = xelatex \documentclass{article} \usepackage{listings} \usepackage[UTF8]{ctex} \usepackage{color} \usepackage{geometry} \usepackage{longtable} \geometry{a4paper,left=1cm,right=1cm,top=1cm,bottom=1cm} \definecolor{codegreen}{rgb}{0,0.6,0} \definecolor{codegray}{rgb}{0.5,0.5,0.5} \definecolor{codepurple}{rgb}{0.58,0,0.82} \definecolor{backcolour}{rgb}{0.95,0.95,0.92} \lstdefinestyle{mystyle}{ backgroundcolor=\color{backcolour}, commentstyle=\color{codegreen}, keywordstyle=\color{magenta}, numberstyle=\tiny\color{codegray}, stringstyle=\color{codepurple}, basicstyle=\small\ttfamily, breakatwhitespace=false, breaklines=true, captionpos=b, keepspaces=true, numbers=left, numbersep=5pt, showspaces=false, showstringspaces=false, showtabs=false, tabsize=4 } \lstset{style=mystyle} \begin{document} \begin{longtable}{|p{2cm}|p{15cm}|} \hline 行一 & \begin{lstlisting} linux command 0 #命令0 linux command 1 #命令1 linux command 2 #命令2 \end{lstlisting}\\\hline 行二 & \\\hline 行三 & \\\hline \end{longtable} \end{document} ``` ![](https://wenda.latexstudio.net/data/attach/190920/HxNKRXOO.png) 就是把上图中,两个蓝色箭头的的空白去掉. 用代码的好处是, 好多命令行中的有下划线之类的字符,不用直接转义.也可以复制出来在终端上直接执行.