这是我的Rust 代码,我要把org-mode 里面的代码片段和文字导出成PDF
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum XContentTypeOptions {
/// 需要检查响应体的 `Content-Type` 头部
NoSniff,
}
impl Header for XContentTypeOptions {
fn header_name() -> &'static str {
NAME
}
fn parse_header(raw: &Raw) -> hyper::error::Result<XContentTypeOptions> {
let value: String = parsing::from_one_raw_str(raw)?;
match value.to_ascii_lowercase().as_str() {
"nosniff" => Ok(XContentTypeOptions::NoSniff),
_ => Err(hyper::error::Error::Header),
}
}
fn fmt_header(&self, f: &mut Formatter) -> fmt::Result {
f.fmt_line(self)
}
}
impl fmt::Display for XContentTypeOptions {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::XContentTypeOptions::*;
match *self {
NoSniff => f.write_str("nosniff"),
}
}
}
但是导出结果如下:
报错如下.
Overfull \hbox (42.01295pt too wide) in paragraph at lines 1155--1156
[][][]$[][][][][] [] [] [] [][][][][][][][][] [] [][][][][][][] [] [][][] [] []
[][][][][] [] [][][][] [] [][][] [] [][][][] [] [][][][][][][] [] [][][][][][][
][][][][][][][][][][][]$[][]
不知
道怎么把这些超长的行弄好,我知道latex 有 \sloppy
但是不知道怎么用到 Org-mode 上面.
还有另外一个问题:
! Package Listings Error: language rust undefined.
latex 导出时报错,但是我自己定义了一个language, 如下:
\\usepackage[T1]{fontenc}
\\usepackage{beramono}
\\usepackage{listings}
\\usepackage{xcolor}
\\definecolor{dkgreen}{rgb}{0,0.6,0}
\\definecolor{gray}{rgb}{0.5,0.5,0.5}
\\definecolor{mauve}{rgb}{0.58,0,0.82}
\\lstdefinestyle{SamrayRustStyle}{
frame=tb,
language=rust,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\\small\\ttfamily},
numbers=none,
numberstyle=\\tiny\\color{gray},
keywordstyle=\\color{blue},
commentstyle=\\color{dkgreen},
stringstyle=\\color{mauve},
frame=single,
breaklines=true,
breakatwhitespace=true,
tabsize=3,
}
我知道在latex 是这么用:
\\begin{document}
\\begin{lstlisting}[style=SamrayRustStyle]
pub fn helloworld (){
println!("Helloworld")
}
\\end{lstlisting}
\\end{document}
在Org-mode 应该怎么对某块Rust 代码应用呢,熟悉Org-mode 和 latex 的同学过来帮忙看看