rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
17.84k stars 1.62k forks source link

Is there a way to force horizontal rules under headings while generating the book? #2427

Closed ksd3 closed 1 month ago

ksd3 commented 1 month ago

Question

I'm sure this is a simple modification, but I was wondering if there was a way to explicitly force mdbook to add horizontal rules underneath headings without the user having to put them in explicitly. I'm getting annoyed looking at the double lines and want the nice horizontal line under Test Header 1 in the generated webpage.

For example, this is what I currently have (some information censored) in a VSCode preview

image

but this is what it looks like in the actual generated book: image

Version

mdbook v0.4.40
ehuss commented 1 month ago

I would suggest using CSS to style your headings as you desire.

ksd3 commented 1 month ago

Thanks. If anyone has the same problem in the future, the solution is as follows:

  1. Create a file in your mdbook directory called 'myfile.css', and put your css in.
  2. In book.toml add the following:
    [output.html]
    additional-css = ["myfile.css"]

This is obvious but it is somewhat difficult to find in the documentation.