Comments (3)
ok, some more corrections in templates.py
`
class ChemTemplate(TexTemplate):
def init(self,**kwargs):
super().init(**kwargs)
self.add_to_preamble("\usepackage{chemfig}")
def set_chemfig(
self,
atom_sep: str = "2em", ## all of these are the defaults in chemfig
chemfig_style:str="",
atom_style:str="",
angle_increment:int=45,
bond_offset:str="2pt",
double_bond_sep:str="2pt",
node_style:str="",
bond_style:str="",
):
set_chemfig = "\\setchemfig{{angle_increment={:d}".format(angle_increment)
if atom_sep:
set_chemfig += ",atom sep={:s}".format(atom_sep)
if chemfig_style:
set_chemfig += ",chemfig style={:s}".format(chemfig_style)
if atom_style:
set_chemfig += ",atom style={:s}".format(atom_style)
if bond_offset:
set_chemfig += ",bond offset={:s}".format(bond_offset)
if double_bond_sep:
set_chemfig += ",double bond sep={:s}".format(double_bond_sep)
if node_style:
set_chemfig += ",node style={:s}".format(node_style)
if bond_style:
set_chemfig += ",bond style={:s}".format(bond_style)
set_chemfig += "}"
print(set_chemfig)
self.add_to_preamble(set_chemfig)
class ChemReactionTemplate(TexTemplate):
def init(self,**kwargs):
super().init(**kwargs)
self.add_to_preamble("\usepackage{chemfig}")
def set_chemfig(
self,
##Individual molecule params
atom_sep: str = "2em", ## all of these are the defaults in chemfig
chemfig_style:str="{}",
atom_style:str="{}",
angle_increment:int=45,
bond_offset:str="2pt",
double_bond_sep:str="2pt",
node_style:str="{}",
bond_style:str="{}",
## Reaction scheme params
arrow_length:int=1,
arrow_angle:int=0,
arrow_style:str="",
debug:str="false",
):
set_chemfig = "\\setchemfig{{angle_increment={:d},arrow angle={:d},arrow coeff={:s}".format(angle_increment,arrow_angle,arrow_length)
if atom_sep:
set_chemfig += ",atom sep={:s}".format(atom_sep)
if chemfig_style:
set_chemfig += ",chemfig style={:s}".format(chemfig_style)
if atom_style:
set_chemfig += ",atom style={:s}".format(atom_style)
if bond_offset:
set_chemfig += ",bond offset={:s}".format(bond_offset)
if double_bond_sep:
set_chemfig += ",double bond sep={:s}".format(double_bond_sep)
if node_style:
set_chemfig += ",node style={:s}".format(node_style)
if bond_style:
set_chemfig += ",bond style={:s}".format(bond_style)
if debug:
set_chemfig += ",scheme debug={:s}".format(debug)
if arrow_style:
set_chemfig += ",arrow styel={:s}".format(arrow_style)
set_chemfig += "}"
print(set_chemfig)
self.add_to_preamble(set_chemfig)
def get_texcode_for_expression(self, expression):
"""Inserts expression verbatim into TeX template.
Parameters
----------
expression : :class:`str`
The string containing the expression to be typeset, e.g. ``$\\sqrt{2}$``
Returns
-------
:class:`str`
LaTeX code based on current template, containing the given ``expression`` and ready for typesetting
"""
return self.body.replace(self.placeholder_text, "\n\\schemestart\n"+expression+"\n\\schemestop\n\n")
def get_texcode_for_expression_in_env(self,expression,environment):
"""Inserts an expression wrapped in a given environment into the TeX template.
Parameters
----------
environment : :class:`str`
The environment in which we should wrap the expression.
expression : :class:`str`
The string containing the expression to be typeset, e.g. ``"$\\sqrt{2}$"``
Returns
-------
:class:`str`
LaTeX code based on template, containing the given expression and ready for typesetting
"""
print(environment)
begin = r"\begin{" + environment + "}" + "\n\\schemestart"
end = "\\schemestop\n" + r"\end{" + environment + "}"
print(begin,end)
return self.body.replace(
self.placeholder_text, "{0}\n{1}\n{2}".format(begin,expression, end)
)
`
from chanim.
After I modified the ChemTemplate and chem_objects.py code the way you did, the generated video (.mp4) has some problems, all the chemical element symbols overlap, but the generated gifs are correct, but I don't know why, sad.
from chanim.
This is almost too long ago for me to remember what I did, how and why.
Let me check later...
from chanim.
Related Issues (17)
- Too much chemfig code exported to TeX-files HOT 1
- ImportError: cannot import name 'SmallDot' from 'manim.mobject.geometry' HOT 1
- How to implement reaction scheme in chanim HOT 7
- LaTeX compiler error
- New Manim Version not compatible HOT 2
- ImportError: cannot import name 'OpenGLMathTex' from 'manim.opengl' HOT 3
- temporary files are saved in the wrong location
- Incompatible with ManimCE v0.17
- compatibility with manim 0.17???
- Bonds not displayed HOT 3
- TexSymbol is not defined HOT 6
- NameError: name 'self' is not defined HOT 1
- Issue with Arrows HOT 9
- Hatched bonds HOT 1
- Examples usage? HOT 4
- OSError: no library called "cairo" was found HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chanim.