我想转换一个markdown 文档将其转换为 LaTeX 格式,以便纳入我的论文。不幸的是,我的命令的输出,
pandoc -f markdown -t latex --standalone msim-eg.md > msimeg.tex
导致输出需要大量的序言项,而这些项我并不想出现在最终文档中:
\documentclass[]{article}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifxetex
\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\else
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\else
\usepackage[utf8]{inputenc}
\fi
\fi
\usepackage{color}
\usepackage{fancyvrb}
\DefineShortVerb[commandchars=\\\{\}]{\|}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
\newcommand{\RegionMarkerTok}[1]{{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\NormalTok}[1]{{#1}}
\usepackage{graphicx}
% We will generate all images so they have a width \maxwidth. This means
% that they will get their normal width if they fit onto the page, but
% are scaled down if they would overflow the margins.
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex,
colorlinks=true,
linkcolor=blue]{hyperref}
\else
\usepackage[unicode=true,
colorlinks=true,
linkcolor=blue]{hyperref}
\fi
\hypersetup{breaklinks=true, pdfborder={0 0 0}}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{0}
我怎样才能让 pandoc 导出而不需要所有这些前导项?(如果没有独立标志,输出是相同的,并且显然需要一个大的前导码。例如:
\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{# Read in the data in long form (normaly read.table() used)}
\NormalTok{c.names <- }\KeywordTok{c}\NormalTok{(}\StringTok{"id"}\NormalTok{, }\StringTok{"age"}\NormalTok{, }\StringTok{"sex"}\NormalTok{)}
\NormalTok{USd <- }\KeywordTok{c}\NormalTok{(}\DecValTok{1}\NormalTok{, }\DecValTok{59}\NormalTok{, }\StringTok{"m"}\NormalTok{, }\DecValTok{2}\NormalTok{, }\DecValTok{54}\NormalTok{, }\StringTok{"m"}\NormalTok{, }\DecValTok{3}\NormalTok{, }\DecValTok{35}\NormalTok{, }\StringTok{"m"}\NormalTok{, }\DecValTok{4}\NormalTok{, }\DecValTok{73}\NormalTok{, }\StringTok{"f"}\NormalTok{, }\DecValTok{5}\NormalTok{, }\DecValTok{49}\NormalTok{, }\StringTok{"f"}\NormalTok{)}
\NormalTok{USd <- }\KeywordTok{matrix}\NormalTok{(USd, }\DataTypeTok{nrow =} \DecValTok{5}\NormalTok{, }\DataTypeTok{byrow =} \NormalTok{T) }\CommentTok{# Convert long data into matrix, by row}
\NormalTok{USd <- }\KeywordTok{data.frame}\NormalTok{(USd) }\CommentTok{# Convert this into a dataframe}
\KeywordTok{names}\NormalTok{(USd) <- c.names }\CommentTok{# Add correct column names}
\NormalTok{USd$age <- }\KeywordTok{as.numeric}\NormalTok{(}\KeywordTok{levels}\NormalTok{(USd$age)[USd$age]) }\CommentTok{# Age is a numeric variable}
\NormalTok{USd }\CommentTok{# Show the data frame in R}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## id age sex
## 1 1 59 m
## 2 2 54 m
## 3 3 35 m
## 4 4 73 f
## 5 5 49 f
\end{verbatim}
\subsubsection{Geographical data}
\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{# Read in the data in long form (normaly read.table() used)}
\NormalTok{category.labels <- }\KeywordTok{c}\NormalTok{(}\StringTok{"16-49"}\NormalTok{, }\StringTok{"50+"} \CommentTok{# Age constraint }
\NormalTok{,}\StringTok{"m"}\NormalTok{, }\StringTok{"f"} \CommentTok{# Sex constraint}
\CommentTok{#,"bicycle", "bus", "car.d", "car.p", "walk" # Mode constraint}
\NormalTok{)}
\NormalTok{all.msim <- }\KeywordTok{c}\NormalTok{( }\DecValTok{8}\NormalTok{, }\DecValTok{4}\NormalTok{, }\DecValTok{6}\NormalTok{, }\DecValTok{6}\NormalTok{, }\CommentTok{#0.001, 1, 8, 1, 0.001, # Car dominated}
\DecValTok{2}\NormalTok{, }\DecValTok{8}\NormalTok{, }\DecValTok{4}\NormalTok{, }\DecValTok{6}\NormalTok{, }\CommentTok{#0.001, 3, 5, 1, 1, # Elderly}
\DecValTok{7}\NormalTok{, }\DecValTok{4}\NormalTok{, }\DecValTok{3}\NormalTok{, }\DecValTok{8}\NormalTok{, }\CommentTok{#1, 2, 5, 2, 1, # Female dominated}
\DecValTok{5}\NormalTok{, }\DecValTok{4}\NormalTok{, }\DecValTok{7}\NormalTok{, }\DecValTok{2}\NormalTok{, }\CommentTok{#2, 1, 3, 1, 2, # Male dominated}
\DecValTok{7}\NormalTok{, }\DecValTok{3}\NormalTok{, }\DecValTok{6}\NormalTok{, }\DecValTok{4} \CommentTok{#, 7, 0.001, 2, 0.001, 1 # Many cyclists, young}
\NormalTok{)}
\NormalTok{all.msim <- }\KeywordTok{matrix}\NormalTok{(all.msim, }\DataTypeTok{nrow =} \DecValTok{5}\NormalTok{, }\DataTypeTok{byrow =} \NormalTok{T) }\CommentTok{# Convert long data into matrix, by row}
\NormalTok{all.msim <- }\KeywordTok{data.frame}\NormalTok{(all.msim) }\CommentTok{# Convert this into a dataframe}
\KeywordTok{names}\NormalTok{(all.msim) <- category.labels }\CommentTok{# Add correct column names}
\NormalTok{all.msim }\CommentTok{# Show the data frame in R}
\end{Highlighting}
)
肯定有一个简单的方法可以消除这种混乱。