Open leogoldman opened 2 years ago
Hi @leogoldman and thanks. (Sorry, while writing I closed the PR by mistake)
I'm a bit conflicted concerning this PR, for three reasons:
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.
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
...)
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:
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
)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.
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!
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.