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

Add ability to set latex text size #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

leogoldman
Copy link
Contributor

Added ability to set latex font size. Default is to not add a size specification (which is equivalent to the current output). If user specifies a latex font size, asserts that font size is string and valid latex font size.

I'm less familiar with HTML, so I'm not exactly sure the right way to create an equivalent, but I'm happy to implement something similar for setting the width percentage in the table style tag if that would help.

@toobaz
Copy link
Collaborator

toobaz commented Feb 4, 2022

Hi @leogoldman and thanks. (Sorry, while writing I closed the PR by mistake)

I'm a bit conflicted concerning this PR, for three reasons:

  1. first, this is an option which is non-trivial to implement consistently across output formats. Leaving aside the way font sizes are actually coded in an html table... what size should \large actually be in html? I'm fine with this PR only implementing LaTeX, but let's code it in such a way that supporting other formats is as straightforwards as possible.

  2. second, what this PR does is "just" to put the string passed at the beginning of the \table environment... which is the right thing to do, of course, but can possibly serve many other purposes (e.g. changing the color, the font face, putting a \vspace...)

  3. even the font sizes accepted are to some extent arbitrary. Yes, they are the standard ones, but for instance the memoir class will accept \HUGE

I think we can take two alternative directions:

  1. create a method that inserts arbitrary code after the opening of the table LaTeX environment (basically what you did, but with a more general name e.g. custom_latex_code, and that can be used multiple time to concatenate, in the style of custom_notes)
  2. create a method font_size that focuses on font size and (eventually) works across formats - which means that the input must be potentially more general.

And thinking about it, the best way to go is probably to do both, whereas font_size should rely, for LaTeX, on custom_latex_code, but should accept both numbers and strings, where numbers should be converted to the closest string. Except that it's really cumbersome. Maybe the opposite is easier (although this page suggests that the scaling factor by, say, \huge depends on the default point size!), and at least one would know that LaTeX sizes are the way to also get consistent HTML (which is quite weird).

I want to think about it a bit more, feel free to share your opinion.

@toobaz toobaz closed this Feb 4, 2022
@toobaz toobaz reopened this Feb 4, 2022
@leogoldman
Copy link
Contributor Author

Hi @toobaz, I think you're right, that ultimately there should be a set_font_size function, which in the case of latex would use add_custom_latex_code. I've started setting that up (changed the method I added before to a more general add_custom_latex_code method) and added a method set_font_size which changes the custom_latex_code attribute if it's input is a string.

More generally, I think if you give a string size (scriptsize, small, etc.), it should just input that in the case of latex. Otherwise, I think the font size input should always be numeric (I don't want to think about string sizes as a latex user I certainly don't want html users to have to consider them). That raises the question of specifying a font size (e.g. 12pt), or a scaling factor, or a percentage. I think that a percentage makes the most sense, as font-size=X% in html seems appropriate and in general I think it's intuitive. For Latex, we could leave it at accepting just strings or add a scaling parameter that basically applies the mapping in the page you linked to, assuming that the document font size is 11pt or something. Maybe we could set that as a broader parameter (I'm thinking like rcParams in matplotlib), or maybe this is all just too much to adjust the font size, and we could just specify that numeric latex font sizes aren't guaranteed accurate. I also added a little bit so that if a numeric font size is given, it does scale in case of an html table (although it doesn't affect the title).

Let me know if you have any thoughts!

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.

None yet

2 participants