-
Notifications
You must be signed in to change notification settings - Fork 391
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
Generates algorithmic environment #57
Comments
There are several caveats. Specifically, IPython supports only MathJax, meaning that it accepts only a single expression. To output more complicated LaTeX document, we need to complie the source directly, and convert the generated file to an image that IPython accepts. In the work above, I used pdflatex and pdf2image. They requires to install external libraries, e.g., texlive with the algorithmicx package (for pdflatex) and Poppler (for pdf2image). |
An option to implement it for IPython is to use immediate newline in the single expression with appropriate manual spacing, but it requires some hacks. I think it would be better to apply external commands to generate the compiled image. |
Can this, if implemented, be added to the |
@luisarandas Yes, the poc works on Jupyter and/or Colab and we can add examples. |
I'd agree with multiple code gen, targeting either Jupyter or algorithmic. I'd be interested in taking a look into algorithmic at some point. |
I have some ideas about this.
This design has also an advantage about programmatic use of this library. We can define a function |
I would think that Would you happen to have the LaTeX code for the example |
We don't need inheritance (and shouldn't adopt inheritance here IMO) because there's basically no advantage over composition in this case. We could define For the first example, I tried to synthesize the following LaTeX environment: |
Maybe an required keyword argument to specify the argument to target? |
I guess you meant some argument to specify the output style. Yes we need to have one for it (and maybe it'd be better to integrate the current |
Maybe adding a That way we could have things like @latexify.function(style=Style.EXPRESSION)
def fact(n):
return 1 if n == 0 else n * fact(n - 1) and we could have Style(str, enum.Enum):
EXPRESSION = "expression"
FUNCTION = "function"
ALGPSEUDOCODE = "algpseudocode" |
Yes. And we should have functions for every choice of style. As this is an essential config, users shouldn't write the style parameter every time. |
I think it might be nice to try to do this using said hacks so that we don't add unnecessary dependancies. I don't think it would actually be that difficult. Do you mind if I try to accomplish this, or did you prefer to go the image approach? |
I don't like the image approach actually, so going with two codegens is fine.
Better to use
Better to use See also my previous example. |
I have worked recently to investigate if we could generate the LaTeX algorithm environment from the function.
Actually it can work like this:
I think this feature is really useful for almost arbitrary functions.
The text was updated successfully, but these errors were encountered: