.latex
저는 LaTeX를 처음 사용하는데 코드 블록이 아래와 같이 보이도록 기존 파일을 수정하려고 합니다 .
I'm a code block and I'm pretty!
Important info goes here.
한 가지 주의할 점은 이것이 LaTeX라는 것입니다.주형pandoc과 함께 사용하고 싶습니다. 따라서 편집할 모든 텍스트가 포함된 다른 파일(이 경우 markdown)과 병렬로 사용됩니다. 다른 사람의 템플릿을 참조하고 복사/붙여넣기 등을 시도했지만 나에게 맞는 코드 블록 형식을 찾을 수 없었습니다. 지금까지 가지고 있는 내용을 아래에 첨부하겠습니다. 제가 수정하고 있는 것은 제가 본 다른 것보다 더 복잡합니다. 업데이트가 필요하기 때문에 직장에서 사용하는 것을 실제로 수정하고 있는데 여기에 있는 일부 내용은 아직 완전히 이해되지 않습니다. 전반적으로 코드 블록(및 와 같은 인라인 강조 표시)을 제외하고는 보이는 방식에 만족합니다 this
.
TLDR: 코드 블록 형식을 실제로 표시하려면 어떻게 해야 합니까? 기본 코드 블록 형식에서 변경된 적이 없습니다. 돕다!
편집: 좀 더 살펴본 후 추가하면
\begin{lstlisting}
Test doc
\end{lstlisting}
이 템플릿에서는 Test doc
내가 원하는 형식으로 표시됩니다. 를 사용하는 다른 파일에서 들어오는 코드 블록의 형식도 지정하도록 라텍스 문서를 얻으려면 어떻게 해야 합니까 ```
?
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$]{$documentclass$}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{longtable}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
% provides \textsubscript
\usepackage{fixltx2e}
%\usepackage{package/garamond}
%\usepackage[T1]{fontenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{titlesec}
\usepackage[export]{adjustbox}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\definecolor{SpecialBlue}{HTML}{2E93CE}
\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.5,0.5,0.5}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{SpecialBlue},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=mystyle}
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[max width=\linewidth]{#1}}
\titleformat{\section}
{\color{SpecialBlue}\normalfont\Large\bf}
{\color{SpecialBlue}\thesection}{1em}{}
% ~~~~~~~~~~~~~~~~~~~~ HEADER & FOOTER ~~~~~~~~~~~~~~~~~~~~
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyhead[R]{\scriptsize $title$\\$date$}
\fancyfoot[L]{{\scriptsize Proprietary and Confidential}}
\fancyfoot[C]{\raisebox{-0.5\height}{\Oldincludegraphics[width=1in]{Special_logo_2020.png}}}
\fancyfoot[R]{\scriptsize Page \thepage}
% use microtype if available
\textwidth = 6.5in
\oddsidemargin = 0in
\hoffset = 0in
\fancyheadoffset{0in}
\fancyfootoffset{0in}
$if(lhs)$
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex]{hyperref}
\else
\usepackage[unicode=true]{hyperref}
\fi
%~~~~~~~~~~~~~~~~~~~~~~~~~~ LINKS ~~~~~~~~~~~~~~~~~~~~~~~~~
\hypersetup{breaklinks=true,
bookmarks=true,
pdfauthor={$author-meta$},
pdftitle={$title-meta$},
colorlinks=false,
urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
pdfborder={0 0 0}}
$if(links-as-notes)$
% Make links footnotes instead of hotlinks:
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
$endif$
$if(strikeout)$
\usepackage[normalem]{ulem}
% avoid problems with \sout in headers with hyperref:
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
$endif$
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
$if(numbersections)$
$else$
\setcounter{secnumdepth}{0}
$endif$
$if(verbatim-in-note)$
\VerbatimFootnotes % allows verbatim text in footnotes
$endif$
$for(header-includes)$
$header-includes$
$endfor$
$if(tables)$
\usepackage{ctable}
\usepackage{float} % provides the H option for float placement
$endif$
$if(title)$
\title{$title$}
$endif$
$if(author)$
\author{$for(author)$$author$$sep$ \and $endfor$}
$endif$
$if(date)$
\date{$date$}
$endif$
%~~~~~~~~~~~~~~~~~~~~~~~~~~~ PAGE ~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
$if(title)$
\maketitle
$endif$
$for(include-before)$
$include-before$
$endfor$
$if(toc)$
{
\hypersetup{linkcolor=black}
\tableofcontents
}
$endif$
\thispagestyle{fancy}
$body$
$if(natbib)$
$if(biblio-files)$
$if(biblio-title)$
$if(book-class)$
\renewcommand\bibname{$biblio-title$}
$else$
\renewcommand\refname{$biblio-title$}
$endif$
$endif$
\bibliography{$biblio-files$}
$endif$
$endif$
$if(biblatex)$
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$
$for(include-after)$
$include-after$
$endfor$
%\ungaramond
\end{document}
답변1
다음 옵션을 추가하여 pandoc
사용하도록 지시해야 합니다 .listings
--listings
pandoc -f markdown -o out.tex --template yourtemplate in.md --listings