Comments (3)
Looking over the Asciidoctor source code, it seems to me that one needs to set @document.attributes['theorem-caption'] = Theorem
for [env.theorem]
, and so on for each new env-role combination encountered. Predefined hash entries of this kind are made at https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/document.rb#L263, and this is also what is suggested by https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/document.rb#L263 .
I've made a stab at doing this in asciidoctor-latex
, but so far have not succeeded.
Here is one attempt:
asciidoctor -r asciidoctor-latex -a stem=latexmath -a theorem-caption=Theorem -b html --verbose try-out/$1.adoc
from asciidoctor-latex.
There are two ways to get auto-numbered captions to work.
Option A: Use built-in behavior
- You must set a document-level attribute named
theorem-caption
to be used in front of the number (can be empty string) (do the assignment in a preprocessor) - The block must have a
title
attribute (which you have done) - The converter method must emit the caption as part of the title using the
captioned_title
method (see https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter/html5.rb#L360)
NOTE: The open block does not use the caption, so you'll need to override this behavior.
If you satisfy (1), then you shouldn't have to manually assign the caption as it's done automatically in the parser (see https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/parser.rb#L1099)
Option B: Use explicit assignment
Another option is to assign the caption explicitly (either to the @caption
property or the title
attribute) by cloning the logic in the assign_caption
method. This is what I meant by using the built-in document counter (see https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/abstract_block.rb#L330).
You'd do something like this in the process
method of the block extension:
env_name = roles.first
env_title = env_name.capitalize
caption_num = parent.document.counter_increment("#{env_name}-number", block)
caption = "#{env_title} #{caption_num}. "
block.assign_caption caption
# alternative approach, set title exactly how you want it
#attrs['title'] = "#{env_title} #{caption_num}"
You are probably better off just filling in the title attribute explicitly with exactly what you want it to display (the last line in the previous listing).
I hope that helps clear things up!
from asciidoctor-latex.
This is now done. Thanks @mojavelinux !
from asciidoctor-latex.
Related Issues (20)
- Proposal to promote project to asciidoctor-latex-plus HOT 9
- dollar signs in source blocks HOT 2
- Equation number in LaTeX example does not produce expected result HOT 1
- Enhancement: Support for LaTeX tables
- Multiple math mode glitches HOT 3
- Negative line number reported in output messages
- Inline stem not quoted in the latex backend HOT 1
- Missing backslash escapes in generated .tex source HOT 1
- Latex conversion of tables with "asciidoctor" style columns fails. Table captions missing too.
- Experimental macros left out HOT 1
- Fix, potentially, for fontspec/pdflatex problem
- asterisk lists aren't converted to lists
- `method_missing': undefined method `convert_environment' HOT 3
- Image captions are not getting generated with `asciidoctor-latex` HOT 4
- asciidoctor-bibtex not working with current version HOT 1
- Multiple errors and dysfunctional .tex file HOT 1
- Non escaped underscore in constrained quotes
- Does Not Handle @ In Emails Correctly HOT 1
- % sign is transcribed as is, causing it to comment rest of line
- Issue with labels in Asciidioc to LaTeX HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asciidoctor-latex.