Skip to content
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

🐛 FIX: changes in source file for pdf build #136

Merged
merged 8 commits into from
Jan 20, 2023
Merged

🐛 FIX: changes in source file for pdf build #136

merged 8 commits into from
Jan 20, 2023

Conversation

AakashGfude
Copy link
Member

No description provided.

@AakashGfude AakashGfude marked this pull request as draft October 20, 2021 12:12
@github-actions
Copy link

github-actions bot commented Oct 20, 2021

@github-actions github-actions bot temporarily deployed to pull request October 20, 2021 12:28 Inactive
@AakashGfude AakashGfude marked this pull request as ready for review October 20, 2021 23:39
@AakashGfude AakashGfude marked this pull request as draft October 20, 2021 23:40
@AakashGfude AakashGfude marked this pull request as ready for review October 27, 2021 01:06
@mmcky
Copy link
Contributor

mmcky commented Nov 29, 2021

@AakashGfude the table of content and contents links don't seem to be clickable on the preview pdf

@AakashGfude
Copy link
Member Author

@AakashGfude the table of content and contents links don't seem to be clickable on the preview pdf

ooh no !! I will rebuild and see, else need to debug.

@AakashGfude
Copy link
Member Author

It looks okay when building locally. Wonder what the reason is.

@AakashGfude
Copy link
Member Author

The CI is using sphinxv4 to build and is throwing errors because of this issue: QuantEcon/quantecon-book-theme#172 .
Will find a concrete solution for that issue and then merge with updates.

@mmcky
Copy link
Contributor

mmcky commented Feb 9, 2022

@AakashGfude just checking in on this PR. Is the upstream issue is now resolved.

@mmcky
Copy link
Contributor

mmcky commented Dec 20, 2022

@jlperla these are some small changes to get PDF builds to work on Julia. Once you update the Julia side of things for 1.8 we can loop around on this one and get PDF builds up and running for whole of site PDF builds.

@mmcky
Copy link
Contributor

mmcky commented Jan 19, 2023

There is an issue with Jupyter-server that needs investigating but will remove this restriction once that is resolved.

jupyter-book/jupyter-book#1902

@github-actions github-actions bot temporarily deployed to pull request January 19, 2023 02:37 Inactive
@mmcky
Copy link
Contributor

mmcky commented Jan 19, 2023

@jlperla this is the latest pdf now that this branch is running.

quantecon-julia.pdf

@AakashGfude I noticed that the table of contents is missing from the pdf. Any ideas?

@github-actions github-actions bot temporarily deployed to pull request January 19, 2023 03:15 Inactive
@mmcky
Copy link
Contributor

mmcky commented Jan 19, 2023

@AakashGfude I have identified the issue.

It is from tools_and_techniques/geom_series.md

```{code-cell} julia
# Creates algebraic symbols that can be used in an algebraic expression
@variables g, r, x0
G = (1 + g)
R = (1 + r)
p0 = x0 / (1 - G * R ^ (-1))
print("Our formula is")
p0
```

When building the Julia lectures if there is generated math from code the ipynb json blob is

   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Our formula is"
     ]
    },
    {
     "data": {
      "text/latex": [
       "$$ \\begin{equation}\n",
       "\\frac{x0}{1 + \\frac{-1 - g}{1 + r}}\n",
       "\\end{equation}\n",
       " $$"
      ],
      "text/plain": [
       "x0 / (1 + (-1 - g) / (1 + r))"
      ]
     },

which gets wrapped in tex as

\begin{sphinxuseclass}{cell_output}
\begin{sphinxVerbatim}[commandchars=\\\{\}]
Our formula is
\end{sphinxVerbatim}
\begin{equation*}
\begin{split} \begin{equation}
\frac{x0}{1 + \frac{-1 - g}{1 + r}}
\end{equation}
 \end{split}
\end{equation*}
\end{sphinxuseclass}\end{sphinxVerbatimOutput}

and xelatex really does not like nested equation environments.

Is this something we could fix in sphinx-jupyterbook-latex?

maybe for Julia we should have nowrap for all math blocks that are generated by code

@mmcky
Copy link
Contributor

mmcky commented Jan 19, 2023

sphinx / Jupyter-book must be interpreting the $$ that is found in returned latex objects in Julia

@mmcky
Copy link
Contributor

mmcky commented Jan 20, 2023

This could be fixed using LaTexify which:

using Latexify
latexify(p0)

which returns in the json blobs

     "data": {
      "text/latex": [
       "\\begin{equation}\n",
       "\\frac{x0}{1 + \\frac{-1 - g}{1 + r}}\n",
       "\\end{equation}\n"

returns LaTeX and no markdown wrappers or delimiters

@jlperla do you know any other settings in Julia Symbolics that might turn off the markdown math delimiters?

@mmcky
Copy link
Contributor

mmcky commented Jan 20, 2023

So the latexify will return the equation but it is wrapped in \begin{equation} such as:

      "text/latex": [
       "\\begin{equation}\n",
       "\\frac{x0}{1 + \\frac{-1 - g}{1 + r}}\n",
       "\\end{equation}\n"
      ],

so we still get double math environments. Will check latexify docs to see if we can not wrap the equation.

@mmcky
Copy link
Contributor

mmcky commented Jan 20, 2023

@AakashGfude SymPy in the python world returns

...
      "text/latex": [
       "$\\displaystyle \\cos{\\left(x \\right)} + 1$"
      ],
      "text/plain": [
       "cos(x) + 1"
      ]

which also includes $ delimiters so I'm now not sure why we are getting double equation environments in the latex writer

@mmcky
Copy link
Contributor

mmcky commented Jan 20, 2023

@jlperla the 7a9d2c7 should fix the issue in the short term but it isn't pretty. Let me know what you think?

@jlperla
Copy link
Member

jlperla commented Jan 20, 2023

Looks good to me! Thanks for finding a workaround

@github-actions github-actions bot temporarily deployed to pull request January 20, 2023 02:50 Inactive
@mmcky mmcky merged commit 6c5f4be into main Jan 20, 2023
@mmcky mmcky deleted the pdf-build branch January 20, 2023 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants