Comments (3)
It looks like the equation numbers are added by the MathJax script when it runs during page load, and there is no numbering added by Asciidoctor that could be used to correctly number the equations. See this excerpt, the stem block, from the _chapter_2.html
output:
<div id="eqn-normalStrain" class="stemblock">
<div class="content">
\[\begin{align}
\epsilon\ (\text{strain}) = \frac{\Delta L\ (\text{change in length})}{L\ (\text{original length})}
\end{align}\]
</div>
</div>
The MathJax script adds the equation numbers as configured in this excerpt, later in _chapter_2.html
:
MathJax.Hub.Config({
TeX: { equationNumbers: { autoNumber: "Equation" } }
})
As you can see, only Asciidoctor knows the reftext of the stem block. MathJax only knows the numbering prefix (and in this case apparently doesn't use it), but not the actual number. So it seems to me like it is not possible to fix this without changes to Asciidoctor. I'll leave this issue open here for now in case someone has opportunity to work on it.
from asciidoctor-multipage.
Thank you for your response @owenh000
Meanwhile, I decided to use the LaTex
\tag{}
. I also made a simple Python
code to update an equation's tag because I did not want to update each tag manually. This may be a crude method, but it served the purpose.
Updated: chap1.adoc
== Chapter 1
This is my chapter one.
[stem#eqn-normalStress,reftext='{eqnums} {counter:eqnum}']
++++
\begin{align}\tag{#eqnum#}
\sigma\ (\text{stress}) = \frac{F\ (\text{load})}{A\ (\text{area})}\ \frac{N}{m^2}
\end{align}
++++
From <<#eqn-normalStress>>, you can calculate the normal stress.
Updated: chap2.adoc
== Chapter 2
This is a test chapter 2.
[stem#eqn-normalStrain,reftext='{eqnums} {counter:eqnum}']
++++
\begin{align}\tag{#eqnum#}
\epsilon\ (\text{strain}) = \frac{\Delta L\ (\text{change in length})}{L\ (\text{original length})}
\end{align}
++++
From <<#eqn-normalStrain>>, you can calculate strain.
Updated: chap3.adoc
== Chapter 3
This is the final test chapter.
[stem#eqn-twistShear,reftext='{eqnums} {counter:eqnum}']
++++
\begin{align}\tag{#eqnum#}
\text{Shear strain, } \gamma = \frac{R\theta}{L}
\end{align}
++++
Calculate shear strain from <<#eqn-twistShear>>.
Python Code to Update \tag{#eqnum#}
main_file = "test.adoc"
start_key_word = "include::"
end_key_word = ".adoc["
eqn_tag = "#eqnum#"
eqn_count = 1
bool_write_line = False
file_names = [main_file[:-5]] # remove .adoc extension
############get all file names as included###############
with open(main_file) as infile:
for line in infile:
if line.startswith(start_key_word):
bool_write_line = end_key_word in line
if bool_write_line:
line = line.split(end_key_word)[0]
line = line.split(start_key_word)[1]
file_names.append(line)
bool_write_line = False
############update equation tags###############
for i in range(len(file_names)):
file_path = file_names[i]+".adoc"
infile = open(file_path, 'r')
lines = infile.readlines()
for i in range(len(lines)):
if eqn_tag in lines[i]:
#print(lines[i]) # original tag
nl = lines[i].replace(eqn_tag, str(eqn_count))
lines[i] = nl
#print(lines[i]) # replaced tag
eqn_count += 1
with open(file_path, 'w') as filehandle:
for listitem in lines:
filehandle.write(f'{listitem}')
from asciidoctor-multipage.
Hi Sam, thanks for sharing your workaround. It might be possible to improve this behavior by doing the following in asciidoctor-multipage: (1) disabling MathJax auto-numbering and (2) adding an explicit Latex tag{}
in each case. Since there isn't (as far as I know) an "equation number" in Asciidoctor, it would use the reftext
value as the tag. But it might be too fragile, require changes to Asciidoctor, and/or break with unrelated upstream changes.
Note :eqnums:
only takes three values; see the Document Attributes Reference. It looks like it just gets reset to AMS
.
Edit: removed a stray parenthesis
from asciidoctor-multipage.
Related Issues (20)
- Preamble affects included attributes HOT 2
- Error in multiparts documents when partnums attribute is specified HOT 1
- Use --out-file break the links to home HOT 1
- Custom `toclevels` / option to keep full TOC HOT 4
- Clarify usage of Cross-References HOT 2
- ToC generated inside block level (a) table cells with toc2 attr set on command line HOT 5
- Wrong numeration of appendix chapters HOT 4
- source highlight style does not extract to a file HOT 6
- Do not generate the configurate theme style file for Rouge highlighter HOT 2
- The tags which are in the section title are escaped HOT 1
- The appendix section number is wrong. HOT 4
- Variables not substituted in TOC HOT 3
- Error: "Failed to execute goal de.saumya.mojo:gem-maven-plugin" HOT 4
- Inheriting included attributes HOT 9
- wrong permissions on /var/lib/gems/3.0.0/gems/asciidoctor-multipage-0.0.16/bin/asciidoctor-multipage ? HOT 1
- Using output file name for first page (--out-file FILE is not supported) HOT 1
- Cannot disable stylesheets across all pages HOT 1
- Page title based on heading title HOT 4
- Rewrite some parts of extension, adding a Page class HOT 1
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-multipage.