Try using PythonTex with Texpad.

Motivation

Reasons for PythonTex

I'm only talking about using pythhon for my experiments, but I think the data can be read by python. On top of that, when I tried to create a pdf, I wish I could automate the following things.

Regarding the last figure, honestly, I think that it is effective when the parameters that affect the figure change at a high rate or when using several similar figures with only the parameters changed.

* Executing python and compiling tex

Since python will be executed every time tex is compiled, it is not possible to regenerate the figure to be inserted by just elaborating one character. (When commands such as platex, dvipdfmx and pythontex are executed together in a build script)

Reasons for Texpad

Texpad · Smoothest way to write LaTeX

There is a charge, but is it 2 weeks for a trial? You can use it. The reason why it is Texpad is that I wanted to be introduced to it by a friend and use it. We are considering an editor for tex, including paid ones. (For now, do you do your best by writing gulp in TexShop or ʻatom`? Reference)

Introduction

Install PythonTex

PythonTeX - TeX Wiki

I couldn't create the / usr / textbin folder with ʻEl Capitan, so I referred to [here](http://qiita.com/hideaki_polisci/items/3afd204449c6cdd995c9), but TexLive PythonTex is included in` from the beginning. Also, I need the Pygments module.

pip install pygments

To do.

There is also a Download MacTex button on the Distribution tab of the Texpad preferences.

Texpad typeset

In TexPad, you can select as follows. You can also run the build script under the project folder with bash by checkingUse.tpbuild script`.

※ bib If you check References, it seems that biber will also be done. I haven't written a dissertation yet, so I'm not sure how to manage it with bib.

TexPad build script

Texpad · Help · Custom Typesetting in Texpad OS X using Build Scripts

A sample is here.

I'm using pyenv, but the pythontex command I wrote in the build script didn't work. The cause was an error that the pygments module that should have been installed is missing. I wasn't sure if it was a problem of the user who executed the build script, but for the time being, I added PYTHONPATH in the build script and it was quite good.

Hello PythonTex!

Basically, you can define a function of python etc. in the{pycode}environment and output it on tex with the \ py command.

The following tex is <img height =" 48px "src =" https://qiita-image-store.s3.amazonaws.com/0/32636/3c371aee-c390-f459-c8a5-fb9daf88f1cd.png " > Becomes.

\begin{pycode}
# -*- coding: UTF-8 -*-

def hello():
  msg = r"Hello \textbf{PythonTex}!"
  return msg
\end{pycode}


\py{hello() + " via py"}

Practice

A Gentle Introduction to PythonTeX

In the slide above, a formula using sympy, a diagram using matplotlib, [webkit2png] ](Https://github.com/adamn/python-webkit2png) is used to insert a web page and automatically generate a table.

However, I used print to output directly in the pycode environment, but I couldn't do it in my own environment. By the way, I am 2.7.

Automatic formula generation

I tried PythonTeX: Embed the output of Python code in a LaTeX document: Hamuyoshi's miscellaneous notes

In the slide above, it is combined with \ newcommand and sympy.

There is a latex command in sympy, but it would be great if you could automatically generate it from the formula you are actually using without having to create a formula with sympy.

I'm thinking of using a Theano based library, so I felt like it might convert the graph structure of the Theano formula to sympy or latex, but I found it. did not. (Look for more, and if you don't have one, you can either write it yourself or write it normally with sympy, but if you write it with sympy, I wonder if you should write it normally with tex. I don't know what the simplication of the differential formula is. Reference )

Presentation of specific examples of data

This seems easy to do.

Creating a table

It's already done with data, but it's about how to actually manage the experimental results before making it into a pdf. There is a strong theory that it is saved in Excel (not plain text), but in that case, I'm thinking of using tabfileio. I would like to write a memorandum again after using it. (For csv, even if there is a module as standard.)

Insert figure

PythonTeX and Matplotlib-Something to write down

\begin{pycode}
・ ・ ・
  pylab.savefig('myplot.pdf')
\end{pycode}

\begin{figure}
\includegraphics{myplot.pdf}
\end{figure}

I feel said. For this, I think that you should save the image once and load it normally with tex.

* Save graph image

If you use rodeo, the hurdle for saving graph images will be lowered with python (it seems to be possible graphically), so I would like to use it. An editor that runs in a browser based on ʻipython`. It seems that the data structure of pandas is displayed in the view.

TikZ

Plot of the Brillouin Function | TikZ example

The above page is luatex and the function is defined by lua and TikZ is made, but isn't it possible to use the python version of this? And sweat

Impressions

It seems that you should finish the experiment as soon as possible before investigating the writing environment. ..

Recommended Posts

Try using PythonTex with Texpad.
Try using matplotlib with PyCharm
Try using folium with anaconda
Try using Python's networkx with AtCoder
Try using Tkinter
Try using docker-py
Try mathematical formulas using Σ with python
Try using cookiecutter
Try using PDFMiner
Try using the camera with Python's OpenCV
Try using geopandas
Try using Dropbox API v2 with Go
Try using Python with Google Cloud Functions
Try using Selenium
Try using scipy
Try using pandas.DataFrame
Try using django-swiftbrowser
Try using matplotlib
Try using tf.metrics
Try using PyODE
Try using conda virtual environment with Jupyter Notebook
Try scraping with Python.
Try using virtualenv (virtualenvwrapper)
[Azure] Try using Azure Functions
Try using virtualenv now
Try using W & B
Try SNN with BindsNET
Try using Django templates.html
[Kaggle] Try using LGBM
Try using Python's feedparser.
Try using Python's Tkinter
Try regression with TensorFlow
Try using Tweepy [Python2.7]
Try using Pytorch's collate_fn
Try projective transformation of images using OpenCV with Python
Try to make RESTful API with MVC using Flask 1.0.2
Using X11 with ubuntu18.04 (C)
Try to factorial with recursion
Try function optimization with Optuna
When using optparse with iPython
Try deep learning with TensorFlow
Using Graphviz with Jupyter Notebook
[S3] CRUD with S3 using Python [Python]
Getting Started with python3 # 3 Try Advanced Computations Using Import Statements
[Python] Try using Tkinter's canvas
Try edge detection with OpenCV
Try using Jupyter's Docker image
Messaging with AMQP using kombu
Try using scikit-learn (1) --K-means clustering
Try implementing RBM with chainer.
Try function optimization using Hyperopt
Try Google Mock with C
Using Quaternion with Python ~ numpy-quaternion ~
Try using Azure Logic Apps
Try programming with a shell!
Try GUI programming with Hy
Try an autoencoder with Pytorch
Try Python output with Haxe 3.2
Try using Kubernetes Client -Python-
Try matrix operation with NumPy
Games using IMU with SenseHat