2015-10-14 43 views
3

當我使用####作爲級別4標題時,pdf(latex)中的輸出在段落開始之前不留行距。例如,R Markdown中的4級標題問題

#### Heading 4 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
when an unknown printer took a galley of type and scrambled it to make a type 
specimen book. 

僅輸出爲PDF(乳膠)看起來像這樣

標題4 Lorem存有簡直是印刷排版行業的虛擬文本。 Lorem Ipsum自從16世紀以來一直是業界標準的虛擬文本,當時一臺未知的打印機採用了一種類型的廚房,並將其製作成樣本書。

我已經閱讀無處不在,r markdown允許1-6#的標題,所以我想弄清楚我在這裏做錯了什麼。

另外我想我可以使用\ sububsubsubsection而不是####作爲標題,但是這給了我一個錯誤。

回答

2

見美香的回答以下問題:

https://tex.stackexchange.com/questions/60209/how-to-add-an-extra-level-of-sections-with-headings-below-subsubsection

添加這段代碼到你的tex頭文件,應該這樣做:

\documentclass{article} 
\makeatletter 
\renewcommand\paragraph{\@startsection{paragraph}{4}{\[email protected]}% 
     {-2.5ex\@plus -1ex \@minus -.25ex}% 
     {1.25ex \@plus .25ex}% 
     {\normalfont\normalsize\bfseries}} 
\makeatother 
\setcounter{secnumdepth}{4} % how many sectioning levels to assign numbers to 
+0

我做了類似的事情,但是非常相似。 – Pdawg

1

這本質上是一個LaTeX風格的問題,而不是(r)降價特定的問題。如果您在YAML頭

--- 
output: 
    pdf_document: 
     keep_tex: true 
--- 

添加到您的文檔(或這些行添加到現有的YAML頭),生成的乳膠文件將得到保存;那麼你可以看看通過LaTeX的文件中看到什麼獲取生成的是:

\ {段標題4} \ {標籤標題-4}

Lorem存有...

問題在於LaTeX中的默認段落樣式不包含換行符。一旦你知道這是怎麼回事,你可以搜索類似this LaTeX incantation from tex.stackexchange.com,創建一個parahdr.tex文件,其中包含

\usepackage{titlesec} 
\titleformat{\paragraph} 
    {\normalfont\bfseries} 
    {} 
    {0pt} 
    {} 

,並在你的YAML頭包括它根據"advanced customization" documentation for PDF output from the rmarkdown package

--- 
output: 
    pdf_document: 
     keep_tex: true 
     includes: 
      in_header: parahdr.tex 
--- 
+0

感謝您的解決方案。它確實有助於以新行開始段落,但標題上沒有章節編號。所以,這很像寫Heading4的粗體。看一下乳膠代碼,問題是在3級標題之後,乳膠認爲更多的標題是段落標題,所以解決這個問題解決了我的問題:) – Pdawg