erwanp / pytexit

Convert a Python expression to a LaTeX formula
https://pytexit.readthedocs.io/
Other
115 stars 31 forks source link

Prime not supported in variable name #28

Open turner-eng opened 3 years ago

turner-eng commented 3 years ago

I want to get N_{Rd}^{\prime} shown below, from variable name N_Rdˆprime, this is a feature similar to auto-recognition of greek letters, can we have this? image

erwanp commented 3 years ago

You could add it directly in this convert_symbol function ?

        elif m == "prime":
            m = r"\prime"

A cleaner implementation would be to generalize this with a dictionary of Latex commands and the equivalent Python name they would replace, similar to unicode_tbl

turner-eng commented 3 years ago

Cool instruction, let me do it.

erwanp commented 3 years ago

Best is if you add a small test to :

  1. make sure it works
  2. make sure it will always work ;)

Test syntax is quite obvious : https://github.com/erwanp/pytexit/blob/master/pytexit/test/test_functions.py#L21

turner-eng commented 3 years ago

I am planning to add some basic operation into the variable_name so that it is better suited for civil engineering calculation, any suggestion to do this?

for the example below, I will have R_designMINUSaction as python name, "MINUS" is the key for "-" in the convert_symbols function. image

turner-eng commented 3 years ago

I think putting new symbols conversion option in convert_symbols function is better, since convert_symbols seems to be component (individual superscript/subscript) based while replace_unicode is whole expression based. Mending the latter will disable us to do the following action carelessly unless we define the subsuming variable in correct order

for example in: Rˆprime=Tˆdprime+1, dprime subsumes prime.

turner-eng commented 3 years ago

This feature is interesting, I want to extend this to allow for even more scenarios (such as simple operations) in the variable name such as the second figure

image

RoutputDIVIDEinput to R{output/input} image