简体   繁体   中英

how to center h1 and h2 html headings in pdf file generated by pandoc

I have simple problem. I have some headings in my html file. Something like

<h1>H1 heading</h1>
<h2>H1 heading</h2>

And I want to use pandoc to have it centered in generated document.

I've tried add to my html something like:

<style>
h1, h2 {
  text-align:center
}
</style>

But it doesn't helped. Have you some ideas how to do it as simply as it is possible?

Many thanks to your answer

Your code should be functional, but it will depend where you positioned it.

Old Style without using.css should be inside <head>...</head>

在此处输入图像描述

<!DOCTYPE html>
<html>

<head>

<style>
h1, h2 {
  text-align:center
}
</style>

</head>

<body>
<h1>H1 heading</h1>
Hello World
<h2>H2 heading</h2>
Hello Space
</body>

</html>

If above is misbehaving raise a bug report with Pandoc

I am uncertain why you have used Pandoc since unless you install the large number of LaTeX dependencies then you will be using Wkhtmltox which on its own (without Pandoc) does the task .

wkhtmltox\bin\wkhtmltopdf.exe file://test.htm test.pdf

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM