Skip to content

Commit

Permalink
make latex handling compatible with new version of jupyter book
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjwilson committed Jul 19, 2024
1 parent 0c2cde3 commit 175ddd4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ecoval/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,13 @@ def fix_r_magic(x):
os.system(f"jupyter-book build {book_dir}/ --builder pdflatex")
# Now the latex file needs to be modified and re-compiled
# open the latex file and ensure tables have an hline after the header
with open(f"{book_dir}/_build/latex/python.tex", "r") as file:
# find latex file in directory
latex_path = glob.glob(f"{book_dir}/_build/latex/*.tex")
if len(latex_path) != 1:
raise ValueError("Boo: Jupyter book's API must have changed!")
latex_path = latex_path[0]

with open(latex_path, "r") as file:
filedata = file.read()

# Replace the target string
Expand Down Expand Up @@ -1023,7 +1029,7 @@ def make_header_bold(x):
filedata = "\n".join(new_lines)

# Write the file out again
with open(f"{book_dir}/_build/latex/python.tex", "w") as file:
with open(latex_path, "w") as file:
file.write(filedata)
makecmd = os.environ.get("MAKE", "make")
# remove the pdf file
Expand Down

0 comments on commit 175ddd4

Please sign in to comment.