kaushalmodi / ox-hugo

A carefully crafted Org exporter back-end for Hugo
https://ox-hugo.scripter.co
GNU General Public License v3.0
882 stars 132 forks source link

Support cross-referencing equations #130

Closed kaushalmodi closed 6 years ago

kaushalmodi commented 6 years ago

See https://github.com/kaushalmodi/ox-hugo/issues/129.

emacsun commented 6 years ago

I use a kind of hybrid mode of the one-post-one-file and one-post-one-subtree. Let me explain it for you.

I am a communication engineer, focusing the channel coding theory. So first, I want to write some summary about channel coding theory. Second, I also want to summarize my learning on math such as matrix, stochastic process and abstract linear. Third, I am very interested in computer science. So I think I can post some articles about computer science.

In summary, I have three section for my static site. Each has an Org file. i.e. math.org communication.org and computer.org. In each file, there are subtrees, each subtree for one post.

kaushalmodi commented 6 years ago

@emacsun

I was reviewing your comment in the original issue:

for equation, it will be like \ref{eq:XXXX} to refer the \label{eq:XXXX}

But looks like that's already supported. Do you have a test case that shows that that does not work?

kaushalmodi commented 6 years ago

Test: https://ox-hugo.scripter.co/test/posts/links-to-equations/

I believe you need to add MathJax JS to the header for those \ref links to work. I add these to the ox-hugo test site HTML headers.

emacsun commented 6 years ago

Hi @kaushalmodi , Here is a minimum case:

`

+HUGO_BASE_DIR: ../

+HUGO_SECTION: telecommunication

+FILETAGS:telecommunication

+SEQ_TODO: TODO NEXT DRAFT DONE

+OPTIONS: *:t <:nil timestamp:nil toc:t

+HUGO_AUTO_SET_LASTMOD: t

** TODO Density Evolution :LDPC:@telecommunication: :PROPERTIES: :EXPORT_FILE_NAME: density-evolution :EXPORT_DATE: <2018-02-05 Mon 14:10> :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :summary "Density evolution plays the foundamental role in designing and analyzing LDPC" :END:

It's easy to get: \begin{eqnarray} \label{eq:7} \sum{i}\lambda{i}&=& 1 \newline \sum{i}\rho{i} &=& 1 \end{eqnarray}

As mentioned in \ref{eq:7}

`

In the webpage opened by chrome, the \ref{eq:7} is replace by ??? (yes, three ?)

I check your newly updated example, It still does not work. I think maybe therebe there is something wrong with my configuration or there is something wrong with the hugo Academic theme.

emacsun commented 6 years ago

Hi, @kaushalmodi Finally, I know why the corss-reference equation does not work for me. It is Hugo Academic theme. By default, the equation does not have a number at the right of the line.

So, after modify the mathjax config, it works!!!, Thank you @kaushalmodi very much.

`

`

kaushalmodi commented 6 years ago

Glad to hear! :) For reference, that MathJax config is what ox-html exports by default.

kaushalmodi commented 6 years ago

Actually, I'll leave this issue open till I document that the Org exported MathJax configuration is required.

kaushalmodi commented 6 years ago

Documented here: https://ox-hugo.scripter.co/doc/equations/