2016-12-06 85 views
0

我使用的是pandoc v 1.18我想添加標題以及頁腳文本。Pandoc LaTex PDF標題和頁腳

我想要完整的控制意味着我想將加熱器文本放置在左側,中間和中間,並且與頁腳相同。

但我無法獲得一個地方顯示。

我在YAML頭在我的降價文件

--- 
header: This is fancy 
footer: So is this 
headertext: This is fancy 
footertext: So is this 
#abstract: This is a pandoc test . . . 

documentclass: report 
output: 
    pdf_document: 
    fontsize: 12pt 
    mainfont: Roboto 
    geometry: [top=2cm, bottom=1.5cm, left=1cm, right=1cm] 
css : pandoc.css 
linkcolor : cyan 
toc : true 
--- 

下面我曾嘗試使用headerheadertext分別爲很好,並沒有正常工作。

回答

1

最簡單的解決方案是添加自定義乳膠標頭。創建工作目錄header.tex並添加類似:

\usepackage{fancyhdr} 

\pagestyle{fancy} 
\fancyhf{} 
\rhead{Fancy on the right} 
\lhead{Fancy on the left} 
\cfoot{Fancy in the footer} 

fancyhdr manual尋求幫助。

然後用pandoc myfile.md -o myfile.pdf -H header.tex編譯。

--- 
output: 
    pdf_document: 
    includes: 
     in-header: header.tex 
--- 

爲了能夠設定在YAML變量中的頭就像你想要的,你需要用rmarkdown latex template(見pandoc manual section about templates)玩:隨着Rmarkdown,這可以在YAML前面的問題設置但您可能會失去使用fancyhdr微調頁眉和頁腳的可能性。

+0

這不適用於documentclass:report,我猜是設計。選擇文檔類作爲書籍,在toc和title之後給出了一些空白頁面。任何想法我該如何刪除它們 – krv

+0

@krv對於'documentclass:report'工作正常(只有第一頁沒有頁眉/頁腳,是正常的)。對於'documentclass:book',空白頁面在這裏是因爲它默認是雙面的。看到這裏:http://tex.stackexchange.com/a/1683/56508刪除頁腳和標題從這些 – scoa

+0

是做了一個複檢與'documentclass:report'工作..謝謝 – krv