LoginSignup
7
11

More than 5 years have passed since last update.

Visual Studio CodeでLatex使えるようにしたらウホウホ論文書けた話

Last updated at Posted at 2018-12-04

※WindowsでTexがインストールされている前提です.

ウホウホした内容

  • ショートカットキーが使えまくる(Ctrl+[とか便利)
  • インデントとかカッコとか自動でやってくれる
  • 環境名打ったらbegin,end自動で出してくれる
  • 参照の候補を出してくれる
    • labelで書いてrefで呼び出す
    • bibtexで書いてciteで呼び出す
  • 数式プレビューしてくれる(地味に嬉しい)

セットアップ

色んな拡張機能を入れて,コンパイルできるようにしていきます.

拡張機能のインストール

1.PowerShellを管理者で起動します.
2.実行ポリシーを変更します.下記コマンドを実行すると変更するか聞かれるのでyしておきます.

Set-ExecutionPolicy RemoteSigned

3.拡張機能を一気にインストールします.コピペでいけます.

code --install-extension coenraads.bracket-pair-colorizer
code --install-extension kisstkondoros.vscode-gutter-preview
code --install-extension oderwat.indent-rainbow
code --install-extension sgryjp.japanese-word-handler
code --install-extension torn4dom4n.latex-support
code --install-extension james-yu.latex-workshop
code --install-extension christian-kohler.path-intellisense

4.実行ポリシーを元に戻します.下記コマンドを実行すると変更するか聞かれるのでyしておきます.

Set-ExecutionPolicy Restricted

VS Codeのコンパイル設定

ここまで来たら【Visual Studio CodeでTeXのコンパイルをできるようにする方法】のコンパイル設定をなぞっていきます.
少しだけ補足しておきます.

  1. VS Codeを起動します.
  2. Ctrl+,でユーザ設定を起動します.
  3. 検索窓の下の・・・を押してsettings.jsonを開きます.

あとは思いっきり書いてある通りにやりました.

おまけのスニペット

スニペット入れたらさらにウホウホできたのでおまけで置いときます.
ファイル->基本設定->ユーザ スニペット->latex
これでjsonファイルが開かれるのでそこにこれをコピペです.
みなさんのtexの環境で登録してください.

latex.json
"include figure": {
    "prefix": "figure",
    "body": [
        "\\\\begin{figure}[tb]",
        "\t\\\\begin{center}",
        "\t\t\\\\includegraphics[height=5.6cm]{$1.eps}",
        "\t\t\\\\caption{$2}",
        "\t\t\\\\label{$3}",
        "\t\\\\end{center}",
        "\\\\end{figure}",
    ],
    "description": "include graphics"
    },
    "include table": {
    "prefix": "table",
    "body": [
        "\\\\begin{table}[tb]",
        "\t\\\\begin{center}",
        "\t\t\\\\begin{tabular}{c|c} \\\\hline",
        "\t\t\t$1&$2",
        "\t\t\\\\end{tabular}",
        "\t\\\\end{center}",
        "\\\\end{figure}",
    ],
    "description": "tabular"
},
7
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
11