Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc/PDF] improvements to TOC style of the PDF manual #43698

Closed

Conversation

inkydragon
Copy link
Member

@inkydragon inkydragon commented Jan 7, 2022

Override latex writeheader to use our custom preamble.

Changes:

  • Show only "part&chapter" in TOC
  • Use compact line spacing in TOC
  • Increase the spacing between chapter numbers and chapter names

xref: #35495

  • Present lesser levels of subchapters in the TOC (It is almost 20 pages right now)
  • The spacing for chapter numbers in the TOC is not sufficient

Output

14p v.s. 3p
image
image

Output PDF: doc-pdf-toc+compact-style+efac0d7794.pdf

fast PDF build

These changes affect only the TOC.
So you can compile only the TOC and ignore the rest of the document, which will speed up the compilation significantly!

Clone my en-toc branch, and build.

@ViralBShah
Copy link
Member

@fredrikekre Does this look good to you?

@ViralBShah ViralBShah added the docsystem The documentation building system label Jan 7, 2022
@fredrikekre
Copy link
Member

Can this be incorporated in Documenter instead?

@inkydragon
Copy link
Member Author

inkydragon commented Jan 7, 2022

It is definitely possible. But I doubt that this custom style will work for all documents that use Documenter.
Later, I'll also add a custom cover for Julia's document, which undoubtedly doesn't fit in Documenter.

Documenter may provide a more flexible way to customize the preamble of a document.
Maybe Documenter could accept a keyword argument specifying the path to a custom preamble.tex and use its contents to replace the existing preamble.

@ViralBShah
Copy link
Member

@fredrikekre Is adding this to Documenter significant effort? Since we have a PR that fixes known issues, would it be ok to merge this and then try to have Documenter implement these as convenient? Perhaps a Documenter issue should be opened up for necessary features.

@inkydragon
Copy link
Member Author

inkydragon commented Jan 14, 2022

Some new idea

function Documenter.Writers.LaTeXWriter.writeheader(io::IO, doc::Documenter.Documents.Document)
    custom = joinpath(doc.user.root, doc.user.source, "assets", "custom.sty")
    isfile(custom) ? cp(custom, "custom.sty"; force = true) : touch("custom.sty")
    custom = joinpath(doc.user.root, doc.user.source, "assets", "preamble.tex")
    isfile(custom) ? cp(custom, "preamble.tex"; force = true) : touch("preamble.tex") # TODO: Use the default preamble
    preamble =
        """
        \\newcommand{\\DocMainTitle}{$(doc.user.sitename)}
        \\newcommand{\\DocVersion}{$(get(ENV, "TRAVIS_TAG", ""))}
        \\newcommand{\\DocAuthors}{$(doc.user.authors)}

        % ---- Insert custom preamble
        \\input{preamble.tex}
        """
    _println(io, preamble)
end

This short preamble passed some variables to TeX, and insert the contents of preamble.tex into the tex file as a preamble.
Users can fully customize preamble by adding their own preamble.tex.

I'll clean up the writeheader implementation first, and then present the new custom preamble API proposal in JuliaDocs/Documenter.jl#1746 for discussion.

@inkydragon
Copy link
Member Author

inkydragon commented Jan 14, 2022

@ViralBShah Do we need a CI for building PDF? Something like: docs.julialang.org/PDFs.yml
The existing CI doctest_linux64 seems to test only the HTML build.


Note: If we turn off code highlighting and then build the PDF, we can save about 90% of build time.

  • 5min: with \usepackage[draft=true]{minted}
  • 55min: Normal

@fredrikekre
Copy link
Member

I mean, since this PR just overrides functions in Documenter, why not move the overrides there?

@inkydragon
Copy link
Member Author

Yes, this pr overrides the Documenter function, mainly to make some changes to TOC style.
I'm not quite sure if this change should be applied to the upstream Documenter, so that all Documenter-based documents are styled the same way.

What this pr actually does is customize the TeX document style generated by Documenter. Maybe this pr can be merged into Documenter, but not all customization changes are necessary to sync upstream.
I'm also going to add Julia's logo to the first page of the document next, so changes like that are no need to merge into Documenter as well.

The main issues here are that Documenter does not currently provide a way to customize the preamble.
The solution I propose is to use the contents of preamble.tex as a preamble if it exists.
I may open a separate pr in Documenter.jl later.

@fredrikekre
Copy link
Member

I mean, it seems like these are improvements that would be useful for everyone building pdf docs with Documenter, no?

@inkydragon
Copy link
Member Author

inkydragon commented Jan 14, 2022

I'm not sure, julia manual is a little bit special.

The manual has so many chapters (116) that by showing only the chapter names, the TOC is as long as any other TOC that shows both chapter and section names.

I also reduced the line spacing of the TOC to further reduce the length of the TOC.
Normally, a typical manual would not have such a long table of contents.

For me, the only thing worth porting upstream is "Increasing the spacing between chapter numbers and chapter names".

Anyway, I opened new pr JuliaDocs/Documenter.jl#1750.

@jebej
Copy link
Contributor

jebej commented Jan 14, 2022

Agreed that this shouldn't go for all documents, and, for what it's worth, I prefer the old style despite the extreme length.

JeffBezanson and others added 15 commits February 24, 2022 17:08
Because we're starting to distribute macOS tarballs as well, let's
codesign them by default, when possible.
…ng#43270)

Local workers now inherit the package environment of the main process,
i.e. the active project, LOAD_PATH, and DEPOT_PATH. This behavior
can be overridden by passing the new `env` keyword argument, or by
passing `--project` in the `exeflags` keyword argument.

Fixes JuliaLang#28781, and closes JuliaLang#42089.


Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
Co-authored-by: Gerhard Aigner <aigner@trium.de>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
…et (JuliaLang#44262)

We collect the relocations (i.e. the GOT slots that is used in the code) for each target
in `tgt.relocs`. Needing a relocation, however, does not imply that the function is cloned
for this target within the group (It does mean that at least one target
in the group has it cloned). The previous version would miss the relocation in this case.

This was triggerred with the following cloning situation

    caller: clone_1
    callee: clone_1, clone_1.clone_3

Since caller.clone_1 may call either callee.clone_1 or callee.clone_1.clone_3 a relocation
for callee will be used and is required to be initialized.
In addition to target 1, target 2 (and in fact target 3) within group 1
will also use caller.clone_1. However, since callee isn't cloned for target 2
the previous version wouldn't have saved this slot in the relocation array.
…ng#44341)

Avoids hashing the input key for empty dictionaries.

Inspired by rust-lang/hashbrown#305.
add note that UpperHessenberg was introduced in 1.3
Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
Moelf and others added 10 commits April 2, 2022 18:17
* improve str macro doc help

* add string macro search result
* graphemes(s, m:n) substring slicing

* variable naming

* whoops

* consolidate tests

* empty-range test

* note complexity

* Update stdlib/Unicode/src/Unicode.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* news fix

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>
* Stricter tests in int.jl

* More tests for coverage.
Put back a few lines that were removed by PR $42703 because they are required to successfully embed Julia with MSVC.
…g#44778)

Thanks to JuliaLang#38180, the removed code seems to be dead because no finalizers should be used anymore to modify dictionaries (it was dangerous). Furthermore, it may help users to detect illegal concurrent writes, since it doesn't recurse and have new error message. There should be no, or even a positive, performance effect.
* faster _log_ext
* test subnormal^float
@inkydragon inkydragon requested review from DilumAluthge and a team as code owners April 5, 2022 15:59
@inkydragon
Copy link
Member Author

It looks like git rebase master messed up the commit log.

I'll open a new pr.

@ViralBShah ViralBShah closed this Apr 5, 2022
@inkydragon
Copy link
Member Author

This pr will be replace by: (Merged) JuliaDocs/Documenter.jl#1750 + (Merged) JuliaDocs/Documenter.jl#1785 + JuliaDocs/Documenter.jl#1788

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docsystem The documentation building system
Projects
None yet
Development

Successfully merging this pull request may close these issues.