3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

mac のターミナルで latex 作業効率化

Last updated at Posted at 2019-03-10

自分の mac に latex の作業環境を構築したのでメモ

前提

対象読者

  • 以下を満たす,私以外の人類
    • macOS を使う人
    • LaTeX で文書を作成する人
    • Vim を使う人

環境

  • macOS Mojave (10.14.3)
    • vim インストール済み
    • latex インストール済み
    • homebrew インストール済み

※ latex のインストールおよび設定方法は他の方の記事を参考にされてください.

各種ソフトウェアの導入

Homebrew で適当に入れてください.
latex の導入は MacTeX のパッケージからインストールするのが楽です.

tmux

$ brew install tmux

ctags

$ brew install ctags

それぞれの説明は他の方の記事に投げます.

設定

Vim

NeoBundle でプラグインの管理をしています
主な目的は vimtex の利用です.

[~/.vimrc]
if has('vim_starting')
    set runtimepath+=~/.vim/bundle/neobundle.vim/
    if !isdirectory(expand("~/.vim/bundle/neobundle.vim/"))
        echo "install NeoBundle..."
        :call system("git clone git://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim")
    endif
endif
call neobundle#begin(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'
"----------------------------------------------------------
NeoBundle 'bronson/vim-trailing-whitespace'
NeoBundle 'itchyny/lightline.vim'
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'nathanaelkane/vim-indent-guides'
NeoBundle 'simeji/winresizer'
NeoBundle 'lervag/vimtex'
"----------------------------------------------------------
call neobundle#end()
filetype plugin indent on
NeoBundleCheck
" --- setting for lightline.vim
set laststatus=2
set showmode
set showcmd
set ruler
" --- setting for vim-indent-guides
let g:indent_guides_enable_on_vim_startup = 1
" --- setting for winresizer
let g:winresizer_vert_resize = 5
" --- vimtex
let g:vimtex_enabled=1
let g:vimtex_view_method='skim'
let g:vimtex_quickfix_open_on_warning = 0
let g:vimtex_compiler_latexmk = {
\    'build_dir': '',
\    'continuous':1,
\    'options': [
\        '-synctex=1',
\    ],
\}
" ---

let maplocalleader = '_'              % LocalLeader を '_' に変更する (デフォルトは '\')
nnoremap <silent> <C-j> :bprev<CR>    % バッファの切り替え(ひとつ前)を Ctrl+j で可能にする
nnoremap <silent> <C-k> :bnext<CR>    % バッファの切り替え(ひとつ次)を Ctrl+j で可能にする

set showmatch matchtime=1
set backspace=2
set autoindent
set smartindent
set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4
set clipboard=unnamed

syntax on
colorscheme desert

tmux

Prefix を Ctrl+s に変更し,キーバインドを Vim 風にしています.

[~/.tmux.conf]
set-option -g default-shell /bin/bash

# Prefix key の変更
set -g prefix C-s 
unbind C-b 

set -g base-index 1
setw -g pane-base-index 1

# vi のキーバインドでペインの移動・リサイズ
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind -r H resize-pane -L 2
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r L resize-pane -R 2

# viのキーバインドを使用する
setw -g mode-keys vi

ctags

latex では往々にして {} で囲まれたキーワードを補完してほしくなります.
また,\cite{}するときは .bib ファイルのラベルを参照するので,その設定も加えています.

[~/.ctags]
--append=yes
--recurse=yes
--langdef=latex
--langmap=latex:.tex
--regex-latex=/\\label\{([^}]*)\}/\1//
--regex-latex=/\\label\*\{([^}]*)\}/\1//
--regex-latex=/\\chapter\{([^}]*)\}/\1//
--regex-latex=/\\chapter\*\{([^}]*)\}/\1//
--regex-latex=/\\section\{([^}]*)\}/\1//
--regex-latex=/\\section\*\{([^}]*)\}/\1//
--regex-latex=/\\subsection\{([^}]*)\}/\1//
--regex-latex=/\\subsection\*\{([^}]*)\}/\1//
--regex-latex=/\\subsubsection\{([^}]*)\}/\1//
--regex-latex=/\\subsubsection\*\{([^}]*)\}/\1//
--regex-latex=/\\newcommand\{\\([^}]*)\}/\1//
--regex-latex=/\\newcommand\*\{\\([^}]*)\}/\1//
--regex-latex=/\\newtheorem\{([^}]*)\}/\1//
--regex-latex=/\\newtheorem\*\{([^}]*)\}/\1//
--regex-latex=/\\begin\{([^}]*)\}/\1//
--regex-latex=/\\begin\*\{([^}]*)\}/\1//
--langdef=bibtex
--langmap=bibtex:.bib
--regex-bibtex=/@article\{([^,]*),/\1//i
--regex-bibtex=/@phdthesis\{([^,]*),/\1//i
--regex-bibtex=/@masterthesis\{([^,]*),/\1//i
--regex-bibtex=/@proceedings\{([^,]*),/\1//i
--regex-bibtex=/@inproceedings\{([^,]*),/\1//i
--regex-bibtex=/@conference\{([^,]*),/\1//i
--regex-bibtex=/@book\{([^,]*),/\1//i
--regex-bibtex=/@booklet\{([^,]*),/\1//i
--regex-bibtex=/@inbook\{([^,]*),/\1//i
--regex-bibtex=/@incollection\{([^,]*),/\1//i
--regex-bibtex=/@manual\{([^,]*),/\1//i
--regex-bibtex=/@techreport\{([^,]*),/\1//i
--regex-bibtex=/@unpablished\{([^,]*),/\1//i
--regex-bibtex=/@misc\{([^,]*),/\1//i

何ができるようになったの?

  • Vim の見た目がきれいになった
  • Vim の自動インデントができるようになった
  • tmux の操作が Vim 風のキー操作でできるようになった
  • ctags が .tex ファイルと .bib ファイルを認識するようになった
  • ctags によって Vim の補完機能が強くなった ← 個人的に一番嬉しい

参考記事

MacTeX:
http://doratex.hatenablog.jp/entry/20180501/1525144736#2

vim:
https://qiita.com/morikooooo/items/9fd41bcd8d1ce9170301

tmux:
https://qiita.com/nl0_blu/items/9d207a70ccc8467f7bab
https://qiita.com/succi0303/items/cb396704493476373edf

ctags:
https://qiita.com/soramugi/items/7014c866b705e2cd0b95
http://ig.hateblo.jp/entry/2014/05/27/221426

3
0
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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?