I am trying to add the latex commands \label and \caption to each images I create in my Visual Studio Code notebooks, so that it can be added to a list of figures. I have two types of images/tables in my notebooks, loaded with IPython.display.Image and loaded with pandas, I am using the library nbconvert to convert to latex.
jupyter nbconvert notebooks/ExperimentNotebook.ipynb --no-input --to latex
Types of loading images/tables:
from IPython.display import Image
Image(filename=os.path.join(constants.path_jankauskas,'searchspace.png'))
summaryjankauskas=pd.read_csv(os.path.join(constants.path_jankauskas,"summaryjankauskas2019.csv"),encoding='utf8')
For the images loaded with Image here is what I tried:
from IPython.display import Image
Image(filename=os.path.join(constants.path_jankauskas,'searchspace.png'),metadata={"label":"fig:teste","caption":"[Short Caption](This is my full caption.\cite\{Jankauskas\)"})
However the result is that in the latex code, the label and legend do not appear.
For the tables loaded with Pandas here is what I tried, based on this :
pd.options.display.latex.repr=True
def _repr_latex_(self,label,caption):
return self.to_latex(label=label,caption=caption)
summaryjankauskas=pd.read_csv(os.path.join(constants.path_jankauskas,"summaryjankauskas2019.csv"),encoding='utf8')
summaryjankauskas=summaryjankauskas.T
summaryjankauskas._repr_latex_ = _repr_latex_(summaryjankauskas,"label_name1",["This is my full caption.\cite\{Jankauskas\}","Short Caption"]) # monkey patch pandas DataFrame
Also the legend and the label do not appear in the latex code.
I have also seen this workaround, however in the case of pandas and Image I dont know how to make the workaround
Does anyone know a workaround to allow me to add the latex commands \label and \caption in my notebook in VScode so that when converted to latex I do not need to modify?