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

Tex use #36

Merged
merged 8 commits into from
Dec 12, 2024
Merged

Tex use #36

merged 8 commits into from
Dec 12, 2024

Conversation

audunth
Copy link
Contributor

@audunth audunth commented Dec 6, 2024

LaTeX is an implicit dependency for cosmoplots. Here, we make the dependency explicit in the Readme.

Also, since Computer Modern is the default LaTeX font, we change to this - anyone with a working LaTeX installation should have access to this font, unlike 'Times' (which is not by default available on Fedora / Arch).

Base automatically changed from python3.13 to main December 6, 2024 08:12
@engeir engeir linked an issue Dec 6, 2024 that may be closed by this pull request
@audunth audunth requested review from engeir and auroradh December 12, 2024 07:42
@audunth
Copy link
Contributor Author

audunth commented Dec 12, 2024

@engeir I've added you to check if this works on ubuntu.
@auroradh same for Mac.

@engeir
Copy link
Member

engeir commented Dec 12, 2024

I guess this depend on the latex distribution that the user has installed? Using tinytex, I run into four missing packages: (with texlive-full i guess it will just work?)

Input

Example from README

import matplotlib.pyplot as plt
import cosmoplots
plt.style.use(["cosmoplots.default"])
import numpy as np

a = np.exp(np.linspace(-3, 1, 100))

# Plotting
fig = plt.figure()
ax1 = plt.gca()
ax1.set_xlabel("X Axis")
ax1.set_ylabel("Y Axis")
base = 2  # Default is 10, but 2 works equally well
# Do plotting ...
ax1.semilogx(a)
# It is recommended to call the change_log_axis_base function after doing all the
# plotting. By default, it will try to infer the scaling used for the axis and only
# adjust accordingly.
cosmoplots.change_log_axis_base(ax1, base=base)
# Plotting
fig = plt.figure()
ax2 = plt.gca()
ax2.set_xlabel("X Axis")
ax2.set_ylabel("Y Axis")
base = 2  # Default is 10, but 2 works equally well
cosmoplots.change_log_axis_base(ax2, "x", base=base)
# Do plotting ...
# If you use "plot", the change_log_axis_base can be called at the top (along with add_axes
# etc.), but using loglog, semilogx, semilogy will re-set, and the change_log_axis_base
# function must be called again.
ax2.plot(a)
plt.savefig("test.png")  # also jpg, pdf

Issues

# issue 1
! LaTeX Error: File `type1cm.sty' not found.
$ tlmgr install type1cm
# issue 2
! LaTeX Error: File `type1ec.sty' not found.
$ tlmgr install cm-super
# issue 3
! LaTeX Error: File `underscore.sty' not found.
$ tlmgr install underscore
# issue 4
...
RuntimeError: Failed to process string with tex because dvipng could not be found
$ tlmgr install dvipng

Successful run

@audunth
Copy link
Contributor Author

audunth commented Dec 12, 2024

Yes, we should probably say it needs TeX-Live. I'll check if this is true.

Does tinytex ship with any fonts? What is the default?

@audunth
Copy link
Contributor Author

audunth commented Dec 12, 2024

@engeir Try with Latin Modern instead.

@engeir
Copy link
Member

engeir commented Dec 12, 2024

@audunth There is no difference for me whether I use the Latin Modern or serif+cm commits, same four packages need to be installed if tinytex is used.

Just tested with texlive-full, in which case it works out-of-the-box, no tlmgr install ... needed.

@audunth
Copy link
Contributor Author

audunth commented Dec 12, 2024

As I expect most (of our) users to have some form of texlive (I had not heard of tinytex before), I think a mention in the Readme is good enough.

On Computer Modern vs Latin Modern, it seems there are reasons to prefer Latin Modern: matplotlib/matplotlib#28172

If none of us have problems with Tex Live + Latin Modern, we stick to that.

@audunth
Copy link
Contributor Author

audunth commented Dec 12, 2024

We have confirmed it works out of the box on mac as well.

@audunth audunth merged commit a5d7e95 into main Dec 12, 2024
10 checks passed
@audunth audunth deleted the tex-use branch December 12, 2024 13:09
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.

LaTex installation required
3 participants