Install and use vim-latexsuite

Source: Internet
Author: User
Installation and Use of vim_latex
I. Installation
Vim-latexsuite is a free software dedicated to combining latex and vim. Although the size is small (the installation file is only 0.21 MB), it is powerful and comfortable to use.
Server. Its latest stable version is 1.5, available from [url = "http://vim-latex.sourceforge.net
/Index. php? Subject = download & title = Download "] sourceforge [/url.

To install vim-latexsuite, you must first install vim (for Unix) or gvim (for Windows) (you can also download it from sf.net, the auxiliary directory and configuration file are automatically generated.

In Windows, the installation process of vim-latex is as follows:
1. If the installation directory of gvim is C:/Vim, you only need to extract the installation file to the C:/Vim/vimfiles directory.
2. Add the following content to the C:/Vim/_ vimrc file.

"REQUIRED. This makes vim invoke latex-suite when you open a tex file.
Filetype plugin on

"IMPORTANT: win32 users will need to have 'shellslash 'set so that latex
"Can be called correctly.
Set shellslash

"IMPORTANT: grep will sometimes skip displaying the file name if you
"Search in a singe file. This will confuse latex-suite. Set your grep
"Program to alway generate a file-name.
Set grepprg = grep/-nH/$ *

"OPTIONAL: This enables automatic indentation as you type.
Filetype indent on

3. Install the Help File
In gvim, enter

  1. : Helptags c:/vim/vimfiles/doc

Copy code

In this way, you can use

  1. : Help latex-suite.txt

Copy code

Command to view the help of vim-latexsuite.
Note: If you do not install the Help file, open the c:/wim/vimfiles/doc/latex-suite.tex file directly, you can also view the help, but set
Some tags cannot be used. If the Help file is installed, you can use the Ctrl +] combination key to directly jump from the place where the tag is referenced to the location of the tag, which is very convenient.

II. Usage skills
The so-called technique is actually a Summary of the help of vim-latexsuite, which is far-fetched. However, if you don't have too much time to complete the help, these things are still a bit useful. The installation directory of vim is c:/vim /.

1. Modify the gvim color scheme.
This is not the stuff of latex-suite, but the default color scheme of white background and black characters is almost the worst among several solutions. I think the better solutions are murphy,
Koehler, torte, and other solutions can be viewed through the palette in the gvim editing menu. To modify the color scheme, add the following content to c:/vim/_ vimrc:

  1. Colo <color scheme>

Copy code

Replace <color scheme> with a suitable scheme.

2. Several shortcut keys for editing
Ctrl + n:

If you add

  1. Set iskeyword + =:

Copy code

Then, when your cursor is behind/ref {fig: In insert mode, you can use this shortcut key to specify a variety of parameters with/label {fig: switch between the figure labels defined at the beginning until the appropriate ones are selected.
Ctrl + j:
It is used for switching between place holder. The so-called place holder is surrounded by <+ and +>. Generally, many macros set by vim-latex will be opened as some place holder. For example, the following format is available for the EFI Expo:

/Begin {figure} [h]
/Centerline {/psfig {figure = <+ eps file +> }}
/Caption {<+ caption text +>}
/Label {fig: <+ label +>}
/End {figure} <++>

The shortcut key will be switched between several places holder, and the switch location will be automatically in the Visual Mode, that is, if the text is input, the original text will be replaced. If the switched place holder is <++>, it is directly deleted (which can be used to jump out of an environment ).
F5:

If you press at preamble, it will automatically Insert at the cursor

  1. Usepackage {package name}

Copy code

.
A list of supported packages is automatically provided. You can select one or manually enter one.
F7:
The command list (including the custom list) is displayed, from which you can select one.

3. Compile
(1) Several shortcut keys
/Ll
:
In non-insert mode, this shortcut can directly compile the source file. By default, a dvi file is generated. If you want to generate ps or pdf
File, which can be set by ": TTarget ps (or pdf. For c:/Vim/vimfiles/ftplugin/latex-suite/texrc

  1. G: Tex_MultipleCompileFormats = ""

Copy code

If you perform multiple compilation settings for a format (dvi by default), the final file in this format will be automatically compiled multiple times, other auxiliary programs will be called when necessary
. For example, if

  1. /Bibliography {}

Copy code

Reference format. Usually, it is compiled multiple times by using the combination of the "bibtex" and "latex. After the DVI file is compiled multiple times, click/ll.
/Lv
:
Open the browser to browse the compiled file. For example, you can directly use Yap to browse the dvi file.
/Ls
:
Locate
Browse. You need to modify the settings in c:/Vim/vimfiles/ftplugin/latex-suite/texrc. Find

TexLet g: Tex_CompileRule_dvi = 'latex-interaction = nonstopmode $ *'

I
Line. Add the-src-specials option before $. In this way, when you use/ls to view the dvi file in non-insert mode, the Yap browser will automatically stay in the appropriate position according to the current cursor position
. You can also perform reverse locating in Yap. First, change the View-> Option-> Inverse of the Yap.
Search-> Command line, changed to "C:/vim/vim62/gvim"-c ": RemoteOpen + % l
% F ". After setting, if you double-click somewhere in Yap, the corresponding tex file will be opened with vim and the cursor will be stuck at the corresponding place.
Note: The above three commands must be input in non-insert mode, and cannot be pressed too slowly, otherwise there will be problems.
(2) Change the compilation object rules
The compilation rule is how to generate a specific format (dvi, ps, pdf) file. You can change it in c:/Vim/vimfiles/ftplugin/latex-suite/texrc.

G: Tex_CompileRule _ <format> = ""

Format statement to reset the compilation rules, such as the above mentioned modifications to the DVI file compilation rules during browsing.
(3) partial compilation
Use the mouse or Shift + cursor to select a piece of text, then press/ll to compile only the selected part, and use/lv to view only the display result of this part. This function is particularly useful for viewing a large piece of formulas that have just been written, and it can speed up and improve efficiency when the article is particularly long.

4. Macro
Vim-latexsuite defines many macros, including various Environment, Font, and Sections. These macros are hard to remember. One of the simplest ways is to view the menus in gvim. If you have defined the shortcut menu items, the corresponding macros will be listed later.
Generally, macros are expanded in the insert mode. For example, the environment, Font, and section are all three uppercase letters starting with E, F, and S. For example, the previously mentioned EFI is a macro, which is automatically expanded into the preceding section.
Figure environment. Some macros used in mathematical environments usually contain two letters, starting. For example, 'a-'z represents/alpha-/zex (lower case), but only partially
Yundun macro. For detailed macro definition, you can view the help of vim-latexsuite.
In addition, some macros are defined in Visual Mode. These macros start with a comma and are followed by two lower-case letters. For example, if you select a text to enter Visual Mode, and then press ", ce" (without quotation marks), the selected text will be automatically changed
/Centerline {selected content}

5. macros
The macros used in the. bib file have four macros: BBB, BBL, BBH, and BBX. You also need to enter them in the insert mode. Their functions are similar, but the expanded content ranges from fewer to more, B-Brief, L-Large, H-Huge, and X-all eXtra.
For example, if you enter BBB, a list is displayed for you to choose from. If you select book, it is automatically inserted.

@ BOOK {<+ key +>,
Author ={<++> },
Editor ={<++> },
Title = {<++> },
Publisher = {<++> },
Year = {<++> },
Otherinfo = {<++>}
} <++>

With the Ctrl-J shortcut, you can quickly enter related items.

6. Usage of <++>
Gvim + latexsuite is automatically added when the macro is expanded. For example, when you press the EEN button:

/Begin {enumerate}
/Item
/End {enumerate} <++>

However, it is annoying to delete <++> each time. In fact, this is a very practical function: press Ctrl + j anywhere in the expanded macro, the cursor will automatically jump to <++> and delete the four characters! This allows you to easily redirect content.

7. multiple pdf generation Rules coexist
In some cases, you may need to generate pdf files in multiple ways. For example, write a thesis
Of
According to tex-> dv I->
Pdf is generated. Usually pdflatex is used to generate a pdf at a time when the magic lamp is used, while some people are still used to following tex-> dvi-> ps
->
Pdf. The general practice is to directly modify g: Tex_CompileRule_pdf to the corresponding compilation command according to the method of modifying the object rules in the above 3 (2. However
If you need to frequently use different rules to generate PDF files, you can also add several new ViewRule and ComplieRule. Still modify c:/Vim
/Vimfiles/ftplugin/latex-suite/texrc file, find

  1. TexLet g: Tex_ViewRule_pdf = 'export rd32'

Copy code

There are two parts in total, one corresponding to the win32 System
,
The other corresponds to the unix system. Assume that four pdf generation schemes may be frequently used, which are directly generated.
(Pdflatex), ps-> pdf (ps2pdf), dvi-> pdf (dvipdfm), dvi-> pdf (dvipdfmx ),
The advantage of using dvipdfmx is that the Chinese PDF file generated by dvipdfmx can be copied and pasted without garbled characters and the size is small, but the generated quality is inferior to that of dvipdfm. First, determine the Four Solutions
Define a name. For example, pdflatex keeps the pdf unchanged. The following three types are pdfs, pdfm, and pdfx in sequence, and their viewing rules are the same as those of pdf:

TexLet g: Tex_ViewRule_pdf = 'export rd32'
TexLet g: Tex_ViewRule_pdfs = 'export rd32'
TexLet g: Tex_ViewRule_pdfm = 'export rd32'
TexLet g: Tex_ViewRule_pdfx = 'export rd32'

Then add CompileRule for each solution and find

  1. TexLet g: Tex_CompileRule_pdf = 'pdflatex-interaction = nonstopmode $ *'

Copy code

Add

TexLet g: Tex_CompileRule_pdfs = 'ps2pdf $ *. Ps'
TexLet g: Tex_CompileRule_pdfm = 'dvipdfm $ *. dvi'
TexLet g: Tex_CompileRule_pdfx = 'dvipdfmx $ *. dvi'

In this way

  1. : TTarget pdfm

Copy code

Command to automatically call dvipdfm, and

  1. : TTarget pdf

Copy code

The pdflatex command is called directly, which is very convenient to switch.

Note: The export rd32 command is not available in Windows. to directly call acrobat in vim-latex to view the PDF file, go
D:/Program
Files/CTeX/texmf/miktex/bin (CTeX installation path) create a new export rd32.bat file, which calls
The absolute path of cmdbat.exe, such as adding the following line

  1. "D:/Program Files/Adobe/Acrobat 7.0/Acrobat/mongobat.exe"

Copy code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.