Custom section commands (listing)? #108
-
The package includes captions for tables and figures. I also need to be able to display code listings. I assumed that the sectioning support would be able to make them. I've created the following package that I thought created the right styles: local base = require("packages.resilient.base")
local package = pl.class(base)
package._name = "listings"
function package:_init(options)
base._init(self)
self:registerStyle("listing-caption-base-number", {}, {})
self:registerStyle("listing-caption-main-number", { inherit = "listing-caption-base-number" }, {
numbering = { before = { text = "Listing " }, after = { text = ".", kern = "iwsp" } },
font = { features = "+smcp" },
})
self:registerStyle("listing-caption-ref-number", { inherit = "listing-caption-base-number" }, {
numbering = { before = { text = "listing " } },
})
self:registerStyle("listing-caption", {}, {
font = { size = "4em" },
paragraph = {
before = { indent = false, vbreak = false },
align = "center",
after = { skip = "medskip" },
},
sectioning = {
counter = { id = "listing", level = 2 },
settings = {
toclevel = 7,
bookmark = false,
goodbreak = false,
},
numberstyle = {
main = "listing-caption-main-number",
reference = "listing-caption-ref-number",
},
},
})
self:registerCommand("listingcaption", function(options, content)
options.style = "listing-caption"
SILE.call("sectioning", options, content)
end, "Listings caption")
end
return package And the following simple test:
The The |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
I'm getting this with your code: Isn't it what you expected? |
Beta Was this translation helpful? Give feedback.
@davidchisnall A standard listing environment was added in v2.6.0 (#112)
I am of course interested in your feedback 🐱
And if it meets your expectation, would you mark this question as "Answered"?