我正在撰写项目报告,并解释我曾经使用的稍微疯狂的不直观的代码,我需要在其中放入大量的示例代码的简短摘录.
如何将代码导入LaTeX:
EDITED(想想我会添加设置,这样人们就不必尝试自己解决这些问题了(取自wikibooks(进一步向下链接)并编辑好看))
不错的设置:
\usepackage{color}
\usepackage{listings}
\lstset{ %
language=C++, % choose the language of the code
basicstyle=\footnotesize, % the size of the fonts that are used for the code
numbers=left, % where to put the line-numbers
numberstyle=\footnotesize, % the size of the fonts that are used for the line-numbers
stepnumber=1, % the step between two line-numbers. If it is 1 each line will be numbered
numbersep=5pt, % how far the line-numbers are from the code
backgroundcolor=\color{white}, % …Run Code Online (Sandbox Code Playgroud) 只是好奇是否有人知道如何在使用latexpdf目标时自定义sphinx输出?我已经看到很多用于html输出的自定义内容,但似乎无法找到自定义pdf输出的任何示例.
具体来说,我有兴趣自定义标题页,页眉,页脚,并可能在内容之前添加几页前面的内容.
有没有人见过这种定制的例子,或者人们在生成pdf时几乎只使用"股票"sphinx输出?谢谢!
当我构建从sphinx生成的LaTeX文件时,TOC条目和节标题是蓝色的.是否有一种简单的方法来禁用这些项目的着色?如果没有,是否有一种简单的方法可以让它们变黑?我的目标是在非彩色打印机上打印文档,当我这样做时,TOC和标题看起来不像文本的其他部分那样暗.
如果可能的话,我想做一个适用于整个文档的更改.
注意:我正在使用howto文档类.
感谢ddbeck的输入,我仔细研究了sphinx.sty哪些颜色需要改变.我按如下方式设置(创建)latex_elements字典conf.py:
mypreamble ='''
\\pagenumbering{arabic}
\\definecolor{TitleColor}{rgb}{0,0,0}
\\definecolor{InnerLinkColor}{rgb}{0,0,0}
'''
latex_elements = {
'papersize':'letterpaper',
'pointsize':'11pt',
'preamble':mypreamble
}
Run Code Online (Sandbox Code Playgroud)
这完全符合我的要求.谢谢ddbeck!
我正在用Python编写一些数学代码,并使用Sphinx生成文档.我知道Sphinx可以在Python文档字符串中处理LaTeX代码; 请参阅http://sphinx.pocoo.org/latest/ext/math.html#module-sphinx.ext.mathbase.如何创建LaTeX宏,例如\newcommand{\cG}{\mathcal{G}},在Python文档字符串中使用?