-
Notifications
You must be signed in to change notification settings - Fork 499
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
numbered toc and sections without dot after the last digit #858
Comments
I use this snippet to remove the trailing dot (save to a file, and call require 'asciidoctor-pdf' unless defined? ::Asciidoctor::Pdf
module AsciidoctorPdfSectionExtensions
def numbered_title opts = {}
unless (@cached_numbered_title ||= nil)
if (slevel = (@level == 0 && @special ? 1 : @level)) == 0
@is_numbered = false
@cached_numbered_title = @cached_formal_numbered_title = title
elsif @numbered && !@caption && slevel <= (@document.attr 'sectnumlevels', 3).to_i
@is_numbered = true
@cached_numbered_title = %(#{sectnum('.', false)} #{title}) # <----- HERE
@cached_formal_numbered_title = if slevel == 1 && @document.doctype == 'book'
%(#{@document.attr 'chapter-label', 'Chapter'} #{@cached_numbered_title}).lstrip
else
@cached_numbered_title
end
else
@is_numbered = false
@cached_numbered_title = @cached_formal_numbered_title = captioned_title
end
end
opts[:formal] ? @cached_formal_numbered_title : @cached_numbered_title
end
end
Asciidoctor::Section.prepend AsciidoctorPdfSectionExtensions The actual change from - @cached_numbered_title = %(#{sectnum} #{title})
+ @cached_numbered_title = %(#{sectnum('.', false)} #{title}) |
I have the same problem. janosvitok, can you tell me how to use your snippet, please? The command you have given is leading me to this output:
Am I missing something? I am in the working directory where the .adoc file and the .rb file are stored. I have to admit that I'm new to bash, asciidoctor and ruby. Maybe that's the problem :) |
Lisa: Did you specify all your usual parameters in addition to the -r ? E.g. your document? |
Hi janosvitok, I couldn't get it to work until now, but I will look further into this, thank you :) I am testing it with a very basic document:
After: I'm getting this:
Packages should be up to date:
|
@lisa-rosenberg TL;DR: either provide path to remove-section-trailing-dot.rb (e.g. -r ./remove-section-trailing-dot.rb or -r /home/asdf/remove-section-trailing-dot.rb) or add -I path (e.g. -I . or -I /home/asdf) |
I'd be interested too. There is no trailing dot in numbering. This is against common convention. |
To move forward, we need a way to express this configuration. It probably belongs in the theme. We need to agree on a key and value. Implementation is then rather trivial I would suspect. |
(it could also be done with a document attribute so it also applies to other converters). |
I'm looking for the name of an option that may exist in other systems, so we can build on established conventions. If we can't find one, we'll have to invent one. |
I'd be interested too. |
@mojavelinux what ever became of this? I would like to use the feature if it's been implemented. |
We're waiting on architecture. That hasn't been solved, so no code can be written yet. Feel free to propose solutions. |
I'd like to see this removed by default. Haven't found this in any book type setting nor in LaTeX. |
We can't simply change behavior on all users. There has to be a setting. Some way to describe that you want different output than what is typical (for Asciidoctor). |
O'Reilly always includes the trailing dot in their books. Other publishers do not. |
Not sure what this means? But either way, not a huge deal to me, just nice to have at this point. |
In order to code it, I need to know what to code. Since there are arguments both for and against it, I've made the decision that it must be controlled through configuration (with the current behavior being the default). And that brings us to this comment:
Until we decide on what that configuration is, the specifications, nothing is going to happen. Feel free to submit proposals. |
I'd say that add two doc attributes:
|
Interesting proposal. How strongly do you feel about the fact that this should be controlled from the document? It seems to me something that is presentation only, and thus should be configured in the theme. (On the other hand, the HTML converter doesn't really have a theme, so we lose the opportunity to configure it there). If we use the attributes, I would make it sectnumseparator and sectnumtrailingseparator (which defaults to sectnumseparator). That way, we could achieve |
I don't have any strong feelings. In fact, I was thinking about something similar, but I've forgotten it when I wrote the proposal. I've proposed attributes for the simple reason that HTML does not have templates, and HTML and PDF numbering should be the same. |
This seems like a great idea. The trailing dots do bother me atm. I think the pair of attributes to specify the interior and trailing delimiter would be ideal. |
The more I think about this, the more I'm convinced it should be done via attributes because multiple converters will need to use it. This change will need to be applied to core, but since Asciidoctor PDF is already overriding the method, we can change it here first, then follow-up in core. |
I think this should be sectnumsuffix. |
I wonder if we should shorten sectnumseparator and sectnumsuffix to just numseparator and numsuffix. The reason is, numbers are also used for blocks like figures (e.g., |
@janosvitok Thanks for responding to my call to architecture, btw. Very helpful. |
I'm strongly interested in this feature because of ISO 2145 and DIN 1421 (explained in Wikipedia article Gliederung - translation). And I would prefer to have different suffixes for figures because I need them like here: |
Is there any update on this feature? |
If there is an update, I can assure you I will post it here. If you want it sooner, you can help by answering the open questions I have floated. If we can't answer those questions, we can't implement a change. |
I'm looking at the hack that @janosvitok provided and that I'm using in my docs every day so I came back to this discussion.
In my opinion there should be separate options for section chapter/part heading and caption numbering. The more options to configure this the better; since a lot of people will want this freedom or need to adhere to certain style guidelines as @habakuk007 also stated. The signifiers are modified using attributes and so I think the rest of the parts that make up the final result should be attributes as well. IMHO the PDF theme should provide "fields" that can be filled via attributes and not hardcode content. What should be configurable in the PDF theme is if the TOC will show the signifier and separator/suffix in the listed items. Right now the signifier is dropped but the suffix is added. Therefore this would work like this: pdf-theme.yml
Keys could be a bit simpler maybe but I didn't want to concatenate too much and lose information here. And I would propose the following for the attributes that control this within the document itself: Section e.g. 1.1. My first sub heading Part numbering: e.g. Part 1.1 - This is the firsty first part Chapter numbering: e.g. Chapter 3 - The problem with formats Captions: e.g. "Caption 1.1: My figure" This way you can have full freedom of what separates the numbering and text (snake_case? no problem). If you wish to remove any of the trailing elements you simply fill it with a space or set it empty (depending what look you need). Not set should be handled as default. |
I appreciate the feedback and I'll give it some thought. My initial reaction is that this is introducing too much complexity into the theme. I don't think that more options to configure is better. More options means more things users have to learn and makes the converter feel too complicated/overwhelming for most. We've had tremendous success with keeping things as simple as possible and letting the converter do the work. It's better for advanced functionality like this to allow the converter to be extended (or Asciidoctor in general) in order to influence the behavior. That would mean extracting the logic that sets up the numbering into an overriddable method. But that can be easier said than done. |
I can only speak for myself but I see it from the other side of the coin. I don't really learn often about something I don't need to configure, it just doesn't come across my attention. If the defaults are sensible, then I most likely will never touch them. But when I have some extrinsic motivation (like requirements or a styleguide) to adhere to and find out there is just no simple way to do achieve it, it's demotivating to say the least. It's really very much easier to ignore something that you don't care about than to invent something that you desperately need; especially when you've got time constraints. |
I understand your perspective, but also understand that I support Asciidoctor close to 24/7, and I can tell you from experience that adding more options makes it harder to support. I have time constraints too, and the more complex the configuration is, the more pressure it puts on those constraints. |
TEX has the contrib package secdot that turns on the trailing dot after the section number. For simplicity the attribute could be :secdot!: to turn off the trailing dot in Asciidoctor. |
Hi, I wonder if there is an opportunity to delete the dot in the numbering after the last digit? I think this is the common convention.
I have:
I search for something like this:
Thank you in advance.
The text was updated successfully, but these errors were encountered: