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

[toc2] Distinguish between (unnumbered) title and (numbered) section headings #1027

Closed
wstomv opened this issue Jul 21, 2017 · 8 comments · Fixed by #1029
Closed

[toc2] Distinguish between (unnumbered) title and (numbered) section headings #1027

wstomv opened this issue Jul 21, 2017 · 8 comments · Fixed by #1029

Comments

@wstomv
Copy link

wstomv commented Jul 21, 2017

Jupyter notebooks support six levels of headings in MarkDown through #...######. The toc2 extension supports numbering of these headings.

However, a document usually has only one title and this title is typically not numbered.

I typically use the level-1 heading (# Title) for the title, and would not want to waste a level of numbering on this.

It would be nice if toc2 would offer an option to interpret the level-1 headings as an unnumbered top-level title, and then start with just one number on level 2. That is, ## Section gives something like 1. Section, and not 1.1. Section.

Or is there another/better way to do notebook titles in MarkDown?

Of course, you could do them using HTML tags to use a larger bold face font. But that would be an awkward solution.

@jcb91
Copy link
Member

jcb91 commented Jul 21, 2017

see #1017 - I think this would do what you're requesting?

@jcb91
Copy link
Member

jcb91 commented Jul 21, 2017

or rather, part of it, since it doesn't adjust the numbering of lower-level headings...

@jfbercher
Copy link
Member

I use the awkward solution to use html tags, via the nice :-) latex_envs extension , provided as a dependency of these contrib nbexetnsions. The latex_envs provides \maketitle and \author commands which can be used to define the title, see for instance here.

The style is defined (and can be changed) in latex_envs.css as

.latex_maintitle{
    margin-top: 22px;
    font-size:40px; 
    color:blue;
    text-align: center; 
    font-weight: bold;
    line-height: 100%;
}

@jfbercher
Copy link
Member

Otherwise, I think that a simple solution would be to add a kind of #nonumber tag in headers, which would be detected and the corresponding headers skipped; of cause the tag will not be rendered. This would solve both #1017 (when applied to the first header) and #1027.

@wstomv
Copy link
Author

wstomv commented Jul 21, 2017

#1017 may be helpful; I don't have a toc2 version that supports it yet; I may give it a try when it is ready for testing.

It is less likely that MarkDown will support separate Title syntax, so such a toc2-based solution is preferable, but still somewhat of a kludge.

It would indeed also be necessary to drop one level on the section numbering, and have the ability to set this per notebook, rather than globally.

@jcb91
Copy link
Member

jcb91 commented Jul 22, 2017

Otherwise, I think that a simple solution would be to add a kind of #nonumber tag in headers>

Sounds like a reasonable plan to me, @jfbercher

It is less likely that MarkDown will support separate Title syntax, so such a toc2-based solution is preferable, but still somewhat of a kludge.

It wouldn't need a separate syntax, just the toc2 code to add an extra (hidden) element, or css class, if the option is in use.

It would indeed also be necessary to drop one level on the section numbering, and have the ability to set this per notebook, rather than globally.

The automatic numbering can be handled by using the method above, and yes, the configuration could be stored per-notebook, as with other options, and I think this would make sense. I'll have a crack at a PR now...

@jfbercher
Copy link
Member

@jcb91 ah ah I've almost have a running solution

@jcb91
Copy link
Member

jcb91 commented Jul 22, 2017

@jcb91 ah ah I've almost have a running solution

haha me too! No css/extra elements needed though.

One thing I'm not clear about is what should happen to a second h1 heading, if the first has been skipped. I'm inclined to consider this as something which the user must avoid, since otherwise the numbering becomes inconsistent, or unclear how it should go - thoughts?

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

Successfully merging a pull request may close this issue.

3 participants