LaTeX and R (a little Python) environment construction with SublimeText3 (Windows)

Make LaTeX and R (a little Python)
easier to use with SublimeText3

Introduction

For my notes. I thought I wouldn't see a site that summarizes TeX in Sublime, so I thought I decided to write about the environment I set up (friend J's Maru Pakuri).

Here's a set of setup steps to make LaTeX and R (a little Python) easier to use with SublimeText3. Be sure to restart Sublime accordingly.

Software to prepare

Software preparation procedure

TeXLive 2019 Install TeX Live by referring to TeX Live --TeX Wiki. For Windows, download the installer by referring to TeX Live / Windows --TeX Wiki. The author refers to ** For network installers ** in Installing TeX Live over the Internet. I installed TeXLive 2019 using ʻinstall-tl-windows.exe`.

To confirm that the installation was successful, press Windows key + R and enter cmd to start the command prompt. When you type latexmk on the command line, the installation is successful if you get the following response:

C:\Users\(User name)>latexmk
Latexmk: This is Latexmk, John Collins, 26 Dec. 2019, version: 4.67.

Latexmk: No file name specified, and I couldn't find any
Use
   latexmk -help
to get usage information
C:\texlive\2019\bin\win32\runscript.tlu:907: command failed with exit code 10:
perl.exe c:\texlive\2019\texmf-dist\scripts\latexmk\latexmk.pl

Sublime Text 3 Download from DOWNLOAD FOR WINDOWS on the official website [Sublime Text 3](http://www.sublimetext.com/" Sublime Text 3 "), Install from Sublime Text Build 3211 x64 Setup.exe.

SumatraPDF Refer to Download SumatraPDF on the TeX Wiki. Official HP SumatraPDF ʻInstaller: Download the installer from SumatraPDF-3.1.2-64-install.exeand RunSublime Text Build 3211 x64 Setup.exe` to install.

R-3.6.2 The Comprehensive R Archive Network(DownloadRforWindows->base) Installer from Download R 3.6.2 for Windows in [R-3.6.2 for Windows](https://cran.r-project.org/bin/windows/base/" R-3.6.2 for Windows ") Download and Install from R-3.6.2-win.exe.

Setup steps

First of all, open Sublime Text and press Ctrl + Shift + P to open Command Palette, Enter and confirm ʻinstall Package installer` and Palette. This completes the installation of ** Package Control **.

Next, install the following three packages.

LaTeXTools Press Ctrl + Shift + P as you did in ** Package Control ** to open the Command Palette. Then enter Package Control: Install Package and Palette to confirm. Enter LaTeXTools in the Palette that appears, and if you decide, ** LaTeX Tools ** will be installed. (A message will be displayed on Sublime Text when the installation is complete.)

Next, set ** LaTeX Tools **. The menu in the upper column of Sublime Text, From the second [Preferences] from the right [Preferences]-> [Package Settings] -> [LaTeXTools] -> [Settings-User] And select.

If \ Sublime Text 3 \ Packages \ User \ LaTeXTools.sublime-settings does not exist,

You do not currently have a personalized
LaTeXTools.sublime-setting file.

Create a copy of the default settings file in your
User directory?

A message like the one above will be displayed. Click [OK].

For LaTeXTools.sublime-settings displayed on Sublime Text, press Ctrl + F and press Enter builder_settings in the search field that appears and find" builder_settings "in (line 398).

And From (line 398)" builder_settings " Add the following content between (line 406) // General settings:.

\User\LaTeXTools.sublime-settings



398 "builder_settings" : {
        "command" : ["latexmk", "-cd",
                "-e", "$latex = 'uplatex %O -no-guess-input-enc -kanji=utf8 -interaction=nonstopmode -synctex=1 %S'",
                "-e", "$biber = 'biber %O --bblencoding=utf8 -u -U --output_safechars %B'",
                "-e", "$bibtex = 'upbibtex %O %B'",
                "-e", "$makeindex = 'upmendex %O -o %D %S'",
                "-e", "$dvipdf = 'dvipdfmx %O -o %D %S'",
                "-f", "-%E", "-norc", "-gg", "-pdfdvi"],
406     // General settings:

After adding the above contents, save with Ctrl + S.

Check if LaTeX can be compiled. Of the following contents After creating text.tex on Sublime Text, press Ctrl + B. The first time you will be asked how to Build, so select Build With LaTeX --Traditional. You can also select the build method from [Tool]-> [Build With ...].

After the operation of Building (the operation status is displayed in the bar at the bottom of the screen) is completed, SumatraPDF is automatically started, and if the contents are displayed normally, the confirmation is completed.

test.tex



\documentclass[a4j]{ujarticle}
\title{ {\LaTeX}test file}
\author{Hoge-Yama-Fuga}
\date{\today}

\begin{document}
\maketitle

\section{Introduction}
Hell

\subsection*{in conclusion}
World 

\end{document}

! !! !! Caution! !! !! ** ** Not \ documentclass [a4j] { jarticle } Use \ documentclass [a4j] { u </ font> jarticle **}!

If the document class is ** jarticle **, it doesn't seem to compile normally ... If you know the reason, please give me some advice.

** Addendum (2020/04/30) ** unknown.png A friend told me that the above corrections are okay.

Let's make it convenient through environment variables!

It seems to be the most complicated part of this article.

If you double-click a sentence on ** SumatraPDF ** by passing it through an environment variable, You will be able to open the source code of the relevant part with ** Sublime Text **.

Press Windows key + R and type control to open the control panel. From the list displayed by entering environment variable in the search field on the upper right Select [System-Edit System Variables]-> Environment Variables. Select [Path] from the [System Variables (S)] list, and double-click or press [Edit (I)]. Add the following Path from [Edit Environment Variable Name]-> [New (N)].

C:\Program Files\Sublime Text 3\

Launch ** SumatraPDF **, click the list in the upper left and select [Settings]-> [Options]. Set the reverse search command line settings as follows.

sublime_text %f:%l

This completes ** setting environment variables **.

To confirm, open test.tex with ** SumatraPDf ** and open Then double-click the [1 Introduction] part in the sentence above ** SumatraPDF **, If you can open (line 10) \ section {Introduction} in ** Sublime Text **, you are successful.

**! !! !! Caution! !! !! ** ** Do not put a ** space in the folder name where the .tex file is located! !! ** ** Example You can see it by checking the above with test.tex placed in the hoge fuga folder.

R-Box Similar to the ** LaTeXTool ** procedure Install ** R-Box ** from Package Control: Install Package.

There is no need to set anything for ** R-Box **.

SendCode Similar to the ** LaTeXTool ** procedure Install ** Send Code ** from Package Control: Install Package.

Set ** SendCode **. This is also the same as the procedure of ** LaTeX Tool ** setting. Select [Preferences]-> [Package Settings]-> [SendCode]-> [Settings].

After that, the settings will be displayed, so enter the following contents on the right side of the setting field.

\User\SendCode.sublime-settings


{
    "prog": "r",
    "r": {
        "prog": "r"
    },
}

By adding the above contents, you can send the ** R ** code written on Sublime Text to ** RGui ** with Ctrl + Enter. However, please note that it is necessary to start ** RGui ** in advance.

Check if it works properly.

R.r


curve(dnorm(x) , -5, 5)

If you press Ctrl + Enter with this line entered, it will be sent to ** RGui **. If the graph of the normal distribution appears on ** RGui **, it is successful.

Syntax settings for Python

About Python indentation

Indentation is responsible for distinguishing blocks in Python code. There are mainly half-width space 4 and Tab, half-width space 2 styles. (Although I rarely see two spaces) In Sublime Text's Python syntax settings, if you set Tab = space for 4, Don't confuse the tab with the space 4 code. (Because it is not recommended to be confused)

First of all, open the .py file with Sublime Text because anything is fine. (It's okay if you make a notepad and open the one with the extension changed to .py)

After that, set in the same way as ** LaTeXTool ** etc. Select [Preferences]-> [Settings-Syntax Specific].

After that, the settings will be displayed, so enter the following contents on the right side of the setting field.

\User\Python.sublime-settings


// These settings override both User and Default settings for the Python syntax
{
    "tab_size": 4,
    "translate_tabs_to_spaces": true
}

Press Tab, and if four half-width spaces are output, the setting is complete.

How to use summary

LaTeX --You can build with Ctrl + B.

-By double-clicking a sentence on ** SumatraPDF **, you can open the source code of that part with
** Sublime Text **.

R -After starting ** RGui **, in ** Sublime Text **, you can send and execute the code by pressing
Ctrl + Enter.

Python --You can output half-width space 4 by pressing Tab.

Things that would be useful if you put them in Sublime

This completes the basic environment configuration, Here are some other packages that you might find useful.

  • Japanize It translates Sublime Text into Japanese. I thought that it would be a problem if the detailed settings were in English, so I added it.

  • ConvertToUTF8 It is a (likely) Package that solves problems related to character codes. If UTF-8 is used as the standard, I think there is nothing wrong with including it.

  • Alignment It's a very convenient Package.

For example, for the following code.

sample.c


int x = 0;
double y = 1;
int z = 10;

By selecting the full range of this code and typing Ctrl + Alt + A

sample.c


int x    = 0;
double y = 1;
int z    = 10;

It adjusts the indent based on =. ** Alignment ** settings Settings-User

Settings-User


{
	"alignment_space_chars": ["=","-"],
}

By setting as above, - will also be adjusted to the standard, It will be convenient to use ** R **. Also, set the ** Alignment ** setting Key Bindings-User You can change the command by setting it. (I'm changing to Ctrl + Shift + A.)

References

-Build UTF-8 LaTeX environment with SublimeText3 (Windows) --Qiita

-Build a Python development environment with Sublime Text 3 on Windows --narito blog

-LaTeX's "bad default" trends and countermeasures --Qiita

-Building a Windows platex writing environment with SublimeText3 + LaTeXTools + TeXLive2015 --Fireworks that are not hot to the touch

-I tried Sublime Text 3 (for compiling Tex) --Himaneko Attorinkusu

Recommended Posts

LaTeX and R (a little Python) environment construction with SublimeText3 (Windows)
Building a Python 3.6 environment with Windows + PowerShell
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
python windows environment construction
Building a python environment with virtualenv and direnv
Building a Docker working environment for R and Python
Build a python virtual environment with virtualenv and virtualenvwrapper
Python environment construction (Windows10 + Emacs)
Python environment construction and TensorFlow
Build a python virtual environment with virtualenv and virtualenvwrapper
Python environment construction under Windows7 environment
Create a decent shell and python environment on Windows
Works with Python and R
OpenJTalk on Windows10 (Speak Japanese with Python from environment construction)
Environment construction of python and opencv
Python environment construction memo on Windows 10
Get started with Python! ~ ① Environment construction ~
Create a virtual environment with Python!
[Python3] Development environment construction << Windows edition >>
Building a virtual environment with Python 3
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
pytorch @ python3.8 environment construction with pipenv
Environment construction with pyenv and pyenv-virtualenv
Create a Python execution environment for Windows with VScode + Remote WSL
Building a Docker working environment for R and Python 2: Japanese support
Building a Windows 7 environment for getting started with machine learning with Python
Build a Python environment on your Mac with Anaconda and PyCharm
Postgres environment construction with Docker I struggled a little, so note
Create a C ++ and Python execution environment with WSL2 + Docker + VSCode
[Pyenv] Building a python environment with ubuntu 16.04
Data pipeline construction with Python and Luigi
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Building a Python3 environment with Amazon Linux2
[Python] Create a virtual environment with Anaconda
A memo with Python2.7 and Python3 on CentOS
Creating a python virtual environment on Windows
VScode environment construction (Windows10, Python, C ++, C, Git)
Python and machine learning environment construction (macOS)
Build a python virtual environment with pyenv
Clean python environment with pythonz and virtualenv
A memo packed with RADEX environment construction
Happy GUI construction with electron and python
Let's get along with Python # 0 (Environment construction)
Windows + gVim + Poetry python development environment construction
[AWS] Create a Python Lambda environment with CodeStar and do Hello World
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Easy construction]
Steps to create a Python virtual environment with VS Code on Windows
Quickly build a python environment for deep learning and data science (Windows)
Python environment construction
python windows environment
python environment construction
Python --Environment construction
Python environment construction
python environment construction
Python3 TensorFlow environment construction (Mac and pyenv virtualenv)
Collecting information from Twitter with Python (Environment construction)
Recommended environment and usage when developing with Python
MacOS 10.11 environment construction: Powerline with Anaconda and Dein.vim
Simply build a Python 3 execution environment on Windows
Python environment construction (Anaconda + VSCode) @ Windows10 [January 2020 version]
Build a python environment with ansible on centos6