This commit is contained in:
143
docs/VS-Code/attachments/latex.json
Normal file
143
docs/VS-Code/attachments/latex.json
Normal file
@@ -0,0 +1,143 @@
|
||||
{
|
||||
// Place your snippets for latex here. Each snippet is defined under a snippet name and has a prefix, body and
|
||||
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
||||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
|
||||
// same ids are connected.
|
||||
// Example:
|
||||
// "Print to console": {
|
||||
// "prefix": "log",
|
||||
// "body": [
|
||||
// "console.log('$1');",
|
||||
// "$2"
|
||||
// ],
|
||||
// "description": "Log output to console"
|
||||
// }
|
||||
"Inclue image": {
|
||||
"prefix": [
|
||||
"\\fig",
|
||||
"\\img"
|
||||
],
|
||||
"body": [
|
||||
"\\begin{figure}[h!]",
|
||||
" \\centering",
|
||||
" \\includegraphics[width=0.${1:5}\\linewidth]{img/$2.png}",
|
||||
" \\caption{$3.}",
|
||||
" \\label{fig:$2}",
|
||||
"\\end{figure}"
|
||||
]
|
||||
},
|
||||
"Include listing": {
|
||||
"prefix": [
|
||||
"\\lst",
|
||||
"\\listing"
|
||||
],
|
||||
"body": [
|
||||
"\\begin{lstlisting}[caption={$1.}, label={lst:$2}]",
|
||||
"$3",
|
||||
"\\end{lstlisting}"
|
||||
]
|
||||
},
|
||||
"Texttt": {
|
||||
"prefix": "\\tt",
|
||||
"body": [
|
||||
"\\texttt{$1}",
|
||||
]
|
||||
},
|
||||
"Textit": {
|
||||
"prefix": "\\it",
|
||||
"body": [
|
||||
"\\textit{$1}",
|
||||
]
|
||||
},
|
||||
"Textbf": {
|
||||
"prefix": "\\bf",
|
||||
"body": [
|
||||
"\\textbf{$1}",
|
||||
]
|
||||
},
|
||||
"Picture reference": {
|
||||
"prefix": [
|
||||
"рис",
|
||||
"Рис"
|
||||
],
|
||||
"body": [
|
||||
"Рис.~\\ref{fig:$1}",
|
||||
]
|
||||
},
|
||||
"Special multiline cell for tables": {
|
||||
"prefix": "\\specialcell",
|
||||
"body": "\\newcommand{\\specialcell}[2][l]{\\begin{tabular}[#1]{@{}l@{}}#2\\end{tabular}}"
|
||||
},
|
||||
"TableX": {
|
||||
// c - это просто колонка с тектом по центру, X - максимальная по ширине
|
||||
"prefix": "\\tablex",
|
||||
"body": [
|
||||
"${1:\\usepackage{tabularx\\}}",
|
||||
"\\begin{table}[h!]",
|
||||
" \\centering",
|
||||
" \\caption{$2.}",
|
||||
" \\footnotesize",
|
||||
" \\begin{tabularx}{\\textwidth}{${3:|X|X|X|}}",
|
||||
" \\hline",
|
||||
" \\textbf{${4:Заголовок 1}} & \\textbf{${5:Заголовок 2}} & \\textbf{${6:Заголовок 3}} \\\\\\",
|
||||
" \\hline",
|
||||
" Один & Два & Три \\\\\\",
|
||||
" \\hline",
|
||||
" \\end{tabularx}",
|
||||
"\\end{table}"
|
||||
]
|
||||
},
|
||||
"Table": {
|
||||
"prefix": "\\table",
|
||||
"body": [
|
||||
"\\begin{table}[h!]",
|
||||
" \\centering",
|
||||
" \\caption{$1.}",
|
||||
" \\footnotesize",
|
||||
" \\begin{tabular}{${2:|c|c|c|}}",
|
||||
" \\hline",
|
||||
" \\textbf{${3:Заголовок 1}} & \\textbf{${4:Заголовок 2}} & \\textbf{${5:Заголовок 3}} \\\\\\",
|
||||
" \\hline",
|
||||
" Один & Два & Три \\\\\\",
|
||||
" \\hline",
|
||||
" \\end{tabular}",
|
||||
"\\end{table}"
|
||||
],
|
||||
},
|
||||
"Literature list": {
|
||||
"prefix": ["\\literature", "\\bibliography"],
|
||||
"body": [
|
||||
"\\newpage",
|
||||
"\\section*{Список литературы}",
|
||||
"\\addcontentsline{toc}{section}{Список литературы}",
|
||||
"",
|
||||
"\\vspace{-1.5cm}",
|
||||
"\\begin{thebibliography}{0}",
|
||||
" \\bibitem{novikov}",
|
||||
" Новиков, Ф. А. <<Дискретная математика для программистов>>. — 3-е изд. — Санкт-Петербург: Питер, 2009. — 383 с.",
|
||||
" \\bibitem{vostrov}",
|
||||
" Востров А. В, <<Лекции по теории графов>> URL: \\url{https://tema.spbstu.ru/tgraph_lect/}, Дата обращения: 17.09.2024",
|
||||
"\\end{thebibliography}",
|
||||
]
|
||||
},
|
||||
"change number": {
|
||||
"prefix": ["\\counter", "\\addtocounter"],
|
||||
"body": [
|
||||
"\\addtocounter{${1:table}}{-1}",
|
||||
]
|
||||
},
|
||||
"include pdf": {
|
||||
"prefix": ["\\includepdf", "\\pdf"],
|
||||
"body": [
|
||||
"${1:\\usepackage{pdfpages\\}}",
|
||||
"${2:\\usepackage{tikz\\}}",
|
||||
"\\addtocounter{figure}{1}",
|
||||
"\\includepdf[pages={1}, fitpaper, pagecommand={",
|
||||
"\\thispagestyle{empty}",
|
||||
" \\begin{tikzpicture}[remember picture, overlay]",
|
||||
" \\node at (current page.south) [anchor=north, yshift=35pt] {\\large{${3:Рис 3. }}};",
|
||||
" \\end{tikzpicture}",
|
||||
"}]{${4:pdf/$5.pdf}}"
|
||||
]
|
||||
}
|
||||
}
|
||||
25
docs/VS-Code/latex.md
Normal file
25
docs/VS-Code/latex.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# LaTeX в VS Code
|
||||
|
||||
## Подготовка
|
||||
|
||||
Вся работа с LaTeX в VS Code завязана на расширении [LaTeX Workshop](https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop). Вот [документация](https://github.com/James-Yu/LaTeX-Workshop/wiki/Install) по установке. Вкратце:
|
||||
|
||||
1. Устанавливаем [Perl](https://strawberryperl.com/)
|
||||
2. Устанавливаем [MikTeX](https://miktex.org/)
|
||||
3. Устанавливаем [LaTeX Workshop](https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop)
|
||||
|
||||
После установки можно открыть любой `.tex` файл и попробовать скомпилировать его (`ctrl + alt + b`), а затем открыть предпросмотр (`ctrl + alt + v`). При сохранении файл будет автоматически компилироваться, а предпросмотр обновляться.
|
||||
|
||||
## Сниппеты
|
||||
|
||||
### Создание
|
||||
В LaTeX очень много повторяющихся конструкций, грех не использовать сниппеты. Нажимаем `ctrl + shift + p` (или `f1`), ищем пункт `Snippets: Configure Snippets`, затем ищем `latex`. Автоматически будет создан файл `latex.json`, в который можно добавлять сниппеты.
|
||||
|
||||
### Использование
|
||||
|
||||
Примеры [сниппетов](attachments/latex.json), которые я использую.
|
||||
|
||||
- `\img` - для вставки картинок.
|
||||
- `\lst` или `\listing` - для вставки листингов.
|
||||
- `\tablex` и `\table` - для вставки таблиц.
|
||||
- `\pdf` - для вставки PDF файлов.
|
||||
Reference in New Issue
Block a user