简体   繁体   English

如何使用LaTeX铸造减少与其他文本的分离?

[英]How to reduce the separation from other text using LaTeX minted?

I want to use the minted package to give me syntax highlighting but it has a spacing of more than a centimeter. 我想使用minted包给我语法高亮,但它的间距超过一厘米。

Setting: 设置:

\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
\setlength{\headsep}{0pt}
\setlength{\topskip}{0pt}
\setlength{\topmargin}{0pt}
\setlength{\topsep}{0pt}
\setlength{\partopsep}{0pt}

does not help at all. 根本没有帮助。 Is there any way to reduce the spacing from the rest of the text? 有没有办法减少文本其余部分的间距?

minted internally uses the Verbatim environment from the fancyvrb package. minted内部使用fancyvrb包中的Verbatim环境。 In the documentation of the implementation, the following formula for the spaces is given: 在实现的文档中,给出了以下空格公式:

 <topskip> = \\topsep + \\partopsep + \\parskip <botskip> = \\topsep + \\partopsep 

And

Except when in label or after nobreak, \\parskip is added with \\addvspace , so that net space is: 除了在标签中或在nobreak之后, \\parskip添加了\\addvspace ,因此净空间为:

 MAX{\\topsep (+\\partopsep) + \\parskip , \\lastskip } 

(The usual \\@item works the same way.) (通常\\@item以同样的方式工作。)

Hence, setting \\partopsep to some other value does the trick; 因此,将\\partopsep设置为其他值就可以了; I've tried it, and you need a negative value to remove the margin: 我已经尝试过了,你需要一个负值去除保证金:

\setlength\partopsep{-\topsep}

This removes most of the space between the text body and the code. 这将删除文本正文和代码之间的大部分空间。 To get a distance of 0.5cm, add its distance to that: 要获得0.5厘米的距离,请将其距离添加到:

\setlength\partopsep{-\topsep}
\addtolength\partopsep{-\parskip}
\addtolength\partopsep{0.5cm}

An implementation can be found in https://tex.stackexchange.com/a/19423 可以在https://tex.stackexchange.com/a/19423中找到实现

I don't see exactly want you want to do. 我不确定你想要做什么。 Do you want to change the line spacing? 你想改变行间距吗? If so you can use 如果是这样,你可以使用

\linespread{1.0}

and play a little bit around with the number in the parentheses. 并用括号中的数字稍微玩一下。

The commands you have given as an example refer to the page environment. 您作为示例给出的命令是指页面环境。 See the Wiki link for additional explanations and examples: 有关其他说明和示例,请参阅Wiki链接:

LaTeX Page Layout 乳胶页面布局

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM