konradm
konradm

Reputation: 83

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

Upvotes: 1

Views: 1447

Answers (1)

K J
K J

Reputation: 11733

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

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

enter image description here

<!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

enter image description here

Upvotes: 2

Related Questions