我正在用markdown写文档。我正在使用神奇的pandoc从markdown源创建docx和tex文件。我想有一个文本框提示和注释的读者编程书籍经常做的方式。我不知道如何做到这一点在markdown。你能帮忙吗?
当前回答
截至2021年9月: 这里有一种方法建立一个文本框在markdown使用html div标签和类'warning'。它在Jupyter Notebook和Typora上工作得很好。 您可以修改背景和字体颜色。
<div class="warning" style='padding:0.1em; background-color:#E9D8FD; color:#69337A'>
<span>
<p style='margin-top:1em; text-align:center'>
<b>On the importance of sentence length</b></p>
<p style='margin-left:1em;'>
This sentence has five words. Here are five more words. Five-word sentences are fine. But several together bocome monotonous. Listen to what is happening. The writing is getting boring. The sound of it drones. It's like a stuck record. The ear demands some variety.<br><br>
Now listen. I vary the sentence length, and I create music. Music. The writing sings. It has a pleasent rhythm, a lilt, a harmony. I use short sentences. And I use sentences of medium length. And sometimes when I am certain the reader is rested, I will engage him with a sentence of considerable length, a sentence that burns with energy and builds with all the impetus of a crescendo, the roll of the drums, the crash of the cymbals -- sounds that say listen to this, it is important.
</p>
<p style='margin-bottom:1em; margin-right:1em; text-align:right; font-family:Georgia'> <b>- Gary Provost</b> <i>(100 Ways to Improve Your Writing, 1985)</i>
</p></span>
</div>
或者(在设计上增加一点——圆角和边框)
<div class="warning" style='background-color:#E9D8FD; color: #69337A; border-left: solid #805AD5 4px; border-radius: 4px; padding:0.7em;'>
<span>
<p style='margin-top:1em; text-align:center'>
<b>On the importance of sentence length</b></p>
<p style='margin-left:1em;'>
This sentence has five words. Here are five more words. Five-word sentences are fine. But several together bocome monotonous. Listen to what is happening. The writing is getting boring. The sound of it drones. It's like a stuck record. The ear demands some variety.<br><br>
Now listen. I vary the sentence length, and I create music. Music. The writing sings. It has a pleasent rhythm, a lilt, a harmony. I use short sentences. And I use sentences of medium length. And sometimes when I am certain the reader is rested, I will engage him with a sentence of considerable length, a sentence that burns with energy and builds with all the impetus of a crescendo, the roll of the drums, the crash of the cymbals -- sounds that say listen to this, it is important.
</p>
<p style='margin-bottom:1em; margin-right:1em; text-align:right; font-family:Georgia'> <b>- Gary Provost</b> <i>(100 Ways to Improve Your Writing, 1985)</i>
</p></span>
</div>
其他回答
这是一个简单的基于乳胶的例子。
---
header-includes:
- \usepackage[most]{tcolorbox}
- \definecolor{light-yellow}{rgb}{1, 0.95, 0.7}
- \newtcolorbox{myquote}{colback=light-yellow,grow to right by=-10mm,grow to left by=-10mm, boxrule=0pt,boxsep=0pt,breakable}
- \newcommand{\todo}[1]{\begin{myquote} \textbf{TODO:} \emph{#1} \end{myquote}}
---
blah blah
\todo{something}
blah
结果是:
不幸的是,因为这是latex,所以你不能再在TODO框中包含markdown(通常这不是一个大问题),并且当转换为PDF以外的格式(例如html)时,它将不起作用。
对于同样的问题,我发现的最简单的解决方案是使用一个多行表,只有一行,没有标题(第一列是图像,第二列是文本):
----------------------- ------------------------------------
![Tip](images/tip.png)\ Table multiline text bla bla bla bla
bla bla bla bla bla bla bla ... the
blank line below is important
----------------------------------------------------------------
另一种可能工作(PDF)的方法是使用Latex默认的fbox指令:
\fbox{My text!}
或FancyBox模块获得更高级的功能(和更好看的盒子):http://www.ctan.org/tex-archive/macros/latex/contrib/fancybox。
使用警告扩展。对于mkdocs,可以在mkdocs中配置。yml文件:
markdown_extensions:
- admonition
然后在md文件中插入注释,如下所示:
!!! note
This is a note.
这里有一个例子。
一行
> hello
> world
你好 世界
多线
方法
> hello
>
> world (new line)
你好 世界(新线)
方法b
> ```shell
> echo hello
> echo world
> ```
回声你好 呼应世界
以下方法工作在GitHub,在GitLab…在Stackoverflow上,现在使用CommonMark!
>用Blockquote制作的一行盒子
用Blockquote制作的单行盒子
“用反划线制作的单行框”
单行盒与反刻度
' ' ' 盒子与三反tick ' ' '
Box made with Triple Backticks
~ ~ ~ 用三个波浪线制作的盒子(删除波浪线之间的空间以使其工作) ~ ~ ~
Box made with Triple Tildes
每行开头有四个空格的方框:
“Sometimes we must let go of our pride and do what is requested of us.”
Padmé Amidala
... 还是用水平线?
三个破折号(——)组成一条水平线:
注意:“你的专注决定了你的现实。——奎刚·金。
对于更多的配置,我强烈推荐优秀的GitLab Markdown指南。 你也可以检查不太详细的GitHub基本格式语法。 您可以使用Babelmark比较Markdown实现。
有用提示:
要强制换行,在行尾放置两个空格; 要转义特殊字符,使用\。
推荐文章
- 差异语法突出显示在Github Markdown
- 我如何创建一个文本框的笔记在markdown?
- 在Markdown中创建一个没有标题的表
- R -降价避免包装加载消息
- 在MarkDown中包含SVG(托管在GitHub上)
- 自动TOC在github风味markdown
- 使用pandoc从Markdown转换为PDF时设置空白大小
- 如何显示数学方程在一般github的markdown(不是github的博客)
- 使用Markdown的Sphinx而不是reST
- 降价和图像对齐
- 如何样式一个JSON块在Github维基?
- 标记“本机”文本对齐方式
- Markdown和包括多个文件
- 降价vs加价——它们有关联吗?
- 如何在降价表中编写列表?