我希望能够使用简单的宏在 LaTeX 文档中插入 Markdown 文本,并且希望该文本始终具有特定的背景颜色(例如浅灰色)。
我尝试使用markdown
打包下面列出的一些没有运气的解决方案:
我认为我面临的挑战是 markdown 本身就是一个块。
这是一个 MWE,我正在尝试为 Markdown 块使用自定义背景颜色(例如浅灰色)。
理想的解决方案是某种宏,例如mymarkdown
。
\documentclass{article}
\usepackage{markdown}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{markdown}
This is now inside Markdown
## Here is a Markdown list
+ Create a list by starting a line with `+`, `-`, or `*`
+ Sub-lists are made by indenting 2 spaces:
- Marker character change forces new list start:
* Ac tristique libero volutpat at
+ Facilisis in pretium nisl aliquet
- Nulla volutpat aliquam velit
+ Very easy!
## Here are some Markdown blockquotes
> Blockquotes can also be nested...
>> ...by using additional greater-than signs right next to each other...
> > > ...or with spaces between arrows.][1]][1]
\end{markdown}
This is now outside of Markdown
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{document}
答案1
您可以在开展业务之前使用tcolorbox
并强制markdown
打开,然后在最后发行。tcolorbox
\end{tcolorbox}
在开始时添加所需的选项\begin{tcolorbox}
(查看非常详细的手册)。
\documentclass{article}
\usepackage{markdown}
\usepackage{tcolorbox}
\usepackage{etoolbox}
\pretocmd{\markdown}{\begin{tcolorbox}}{}{}
\def\endmarkdown{\end{tcolorbox}}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
%\begin{tcolorbox}
\begin{markdown}
This is now inside Markdown
## Here is a Markdown list
+ Create a list by starting a line with `+`, `-`, or `*`
+ Sub-lists are made by indenting 2 spaces:
- Marker character change forces new list start:
* Ac tristique libero volutpat at
+ Facilisis in pretium nisl aliquet
- Nulla volutpat aliquam velit
+ Very easy!
## Here are some Markdown blockquotes
> Blockquotes can also be nested...
>> ...by using additional greater-than signs right next to each other...
> > > ...or with spaces between arrows.][1]][1]
\end{markdown}
%\end{tcolorbox}
This is now outside of Markdown
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{document}