2017-12-26 14 views
1

aligngatherのような環境は、文書テキストと数学環境の開始の間の2つの改行が2つのパラグラフ分の垂直な空白を挿入するため、LaTeXテキストの段落内で使用するためにはっきりと設計されています。 Markdownは、Markdownコード/テキストのまったく同じ行で環境を開始したとしても、その上にあるテキストの2行下のLaTeX環境を常に開始します。一行改行。マークダウンに固有の複数行の数学の表示がないので、これはジレンマを引き起こす。R Markdownが新しい段落にLaTeX環境を置くのを防ぐ方法はありますか?

\vspace{-\baselineskip}を実行する前に実行してください。ただし、markdownに最初に改行を挿入しないように指示する方がいいでしょう。それは可能ですか?そしてもしそうでなければ、それぞれの始まりの前に自動的に\vspace{-\baselineskip}を実行する最も簡単な方法は、環境を整列させる(そして/または整列する*、集める、集める、など)環境ですか?

MWE:

--- 
output: 
    pdf_document: 
    keep_tex: 1 
header-includes: 
    - \usepackage{etoolbox} 
    - \AtBeginEnvironment{gather}{\vspace{-\baselineskip}} 
    - \AtBeginEnvironment{gather*}{\vspace{-\baselineskip}} 
--- 

The following environment will get marked up with an extra two lines between it and 
this text, putting it on a new paragraph and creating a lot of whitespace above it, 
whether or not there's any line breaks in the markdown code: 
\begin{gather*} 
A \\ B 
\end{gather*} 

This can of course be hackily corrected by subtracting vertical space: 
\begin{gather*} 
A \\ B 
\end{gather*} 

これは、しかし、ではありません:あなたはこのような状況でできる最善のetoolbox packageを自動的に使用して、すべての特定の環境の開始時に\vspace{-\baselineskip}を挿入することである

--- 
output: 
    pdf_document: 
    keep_tex: 1 
--- 

The following environment will get marked up with an extra two lines between it and 
this text, putting it on a new paragraph and creating a lot of whitespace above it, 
whether or not there's any line breaks in the markdown code: 
\begin{gather*} 
A \\ B 
\end{gather*} 

This can of course be hackily corrected by subtracting vertical space: 
\vspace{-\baselineskip} \begin{gather*} 
A \\ B 
\end{gather*} 

答えて

0

環境によって挿入されるギャップは、前の段落で終わるテキストの量に依存するため、最適です。 Pandocの処理の結果として、量は常に(\abovedisplayskip)と同じであるので、あなたはすべてのamsmath関連の表示位置合わせのためにこれを行う必要があるでしょう

header-includes: 
    - \usepackage{etoolbox} 
    - \AtBeginEnvironment{gather}{\vspace{\dimexpr-\baselineskip-\abovedisplayskip}} 
    - \AtBeginEnvironment{gather*}{\vspace{\dimexpr-\baselineskip-\abovedisplayskip}} 

を使用するように、「より良い」であってもよいです。

関連する問題