%!TEX TS-program = xelatex \documentclass[12pt, a4paper]{article} \usepackage{amsmath,amsfonts,amssymb,amsthm,mathtools} % пакеты для математики %%%%%%%%%%%%%%%%%%%%%%%% Шрифты %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[british,russian]{babel} % выбор языка для документа \usepackage[utf8]{inputenc} % задание utf8 кодировки исходного tex файла \usepackage{fontspec} % пакет для подгрузки шрифтов \setmainfont{Arial} % задаёт основной шрифт документа \usepackage{unicode-math} % пакет для установки математического шрифта %\setmathfont{Asana Math} % шрифт для математики %%%%%%%%%% Работа с картинками %%%%%%%%% \usepackage{graphicx} % Для вставки рисунков \usepackage{graphics} \graphicspath{{images/}{pictures/}} % можно указать папки с картинками \usepackage{wrapfig} % Обтекание рисунков и таблиц текстом %%%%%%%%%% Работа с таблицами %%%%%%%%%% \usepackage{tabularx} % новые типы колонок \usepackage{tabulary} % и ещё новые типы колонок \usepackage{array} % Дополнительная работа с таблицами \usepackage{longtable} % Длинные таблицы \usepackage{multirow} % Слияние строк в таблице \usepackage{float} % возможность позиционировать объекты в нужном месте \usepackage{booktabs} % таблицы как в книгах! \renewcommand{\arraystretch}{1.3} % больше расстояние между строками % Заповеди из документации к booktabs: % 1. Будь проще! Глазам должно быть комфортно % 2. Не используйте вертикальные линни % 3. Не используйте двойные линии. Как правило, достаточно трёх горизонтальных линий % 4. Единицы измерения - в шапку таблицы % 5. Не сокращайте .1 вместо 0.1 % 6. Повторяющееся значение повторяйте, а не говорите "то же" % 7. Есть сомнения? Выравнивай по левому краю! %%%%%%%%%%%%%%%%%%%%%%%% Оформление %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[paper=a4paper,top=15mm, bottom=15mm,left=35mm,right=10mm,includefoot]{geometry} \usepackage{indentfirst} % установка отступа в первом абзаце главы %%%%%%%%%%%%%%%%%%%%%%%% Графики и рисование %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{tikz, pgfplots} % язык для рисования графики из latex'a % Всякие странные команды из Geogebra и с сайта для TikZ \usepackage{pgf} \usepackage{mathrsfs} \usetikzlibrary{arrows} \pagestyle{empty} \definecolor{ffzzzz}{rgb}{1.,0.6,0.6} \definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.} \definecolor{qqqqff}{rgb}{0.,0.,1.} \definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882} \usetikzlibrary{calc} \usepackage{relsize} \newcommand\LM{\ensuremath{\mathit{LM}}} \newcommand\IS{\ensuremath{\mathit{IS}}} \usepackage{pgf,tikz} \usepackage{mathrsfs} \usetikzlibrary{arrows} \pagestyle{empty} \definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1.} \definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882} \title{Графика в LaTeX, TikZ} \date{\today} \begin{document} % конец преамбулы, начало документа \section{Великий и могучий Tikz} \subsection{ Основные команды} % Никогда не забывать в конце каждой строки ставить ; % Tikz очень капризен по отношению к этому! % Все примеры из этой презентации: https://www.overleaf.com/static/latex/learn/free-online-introduction-to-latex-part-3.pdf \begin{tikzpicture} \draw (0,0) -- (1,1); % a line \end{tikzpicture} \vspace{2cm} % сетка координат для удобства (мало ли) \begin{tikzpicture} \draw[help lines] (0,0) grid (3,3); \end{tikzpicture} \vspace{2cm} \begin{tikzpicture} \draw[help lines] (0,0) grid (3,3); \draw[->] (0,0) -- (1,1); \draw[<->, thick] (2,1) -- (1,2); \draw[<-, thick, dashed] (2,2)--(3,3); \end{tikzpicture} \vspace{2cm} \begin{tikzpicture} \draw[help lines] (0,0) grid (3,3); % axes: \draw[<->, thick] (0,3)--(0,0)--(3,0); % diamond: \draw (1.5,0.5) -- (2.5,1.5) -- (1.5,2.5) -- (0.5,1.5) -- cycle; % close the path \end{tikzpicture} \vspace{2cm} \begin{tikzpicture} \draw[help lines] (0,0) grid (3,3); % axes \draw[<->, thick, red] (0,3)--(0,0)--(3,0); % diamond \draw[thick, blue, fill=yellow] (1.5,0.5) -- (2.5,1.5) -- (1.5,2.5) -- (0.5,1.5) -- cycle; \end{tikzpicture} \vspace{2cm} \begin{tikzpicture} \draw[help lines] (0,0) grid (3,3); \draw (1.5,2.0) circle (0.5); \draw (0.5,0.5) rectangle (2.5,1.5); \end{tikzpicture} \vspace{2cm} \begin{tikzpicture} \draw[help lines] (0,0) grid (3,3); \node (h) at (0,0) {H}; \node (x) at (1.5,1.5) {$\xi$}; \node (t) at (3,0) {T}; \draw[->] (x) -- (h); \draw[->] (x) -- (t); \end{tikzpicture} %\draw [domain=:] plot (\x, {function}) \begin{tikzpicture}[scale=0.5] % y axis \draw[<->, thick] (0,2) -- (0,-2); % x axis \draw[ ->, thick] (0,0) -- (7, 0); % curves \draw[cyan,domain=0:2*pi] plot (\x, {sin(\x r)}); \draw[magenta,domain=0:2*pi] plot (\x, {cos(\x r)}); \end{tikzpicture} \vspace{2cm} % циклы \begin{tikzpicture} \foreach \x in {0,...,9} \draw [->] (\x,0)--(\x,-1); \end{tikzpicture} \vspace{2cm} \begin{tikzpicture}[scale=2] \draw[fill] (0.5,0.75) circle [radius=0.025]; \node [below right, red] at (0.5,0.75) {below right}; \node [above left, green] at (0.5,0.75) {above left}; \node [below left, purple] at (0.5,0.75) {below left}; \node [above right, magenta] at (0.5,0.75) {above right}; \end{tikzpicture} % измнение scale не изменяет размер текста =( \newpage \subsection{Пример рисунка} \begin{figure}[H] \begin{minipage}[H]{0.39\linewidth} \begin{center} \[ f(p) = \begin{cases} 2p&, p \in [0;1] \\ 0&, \text{иначе.}\\ \end{cases} \] \end{center} \end{minipage} \hfill \begin{minipage}[H]{0.59\linewidth} \begin{center} \begin{tikzpicture}[scale=0.8] % оси \draw [->] (-3.8,0) -- (4,0); \draw [->] (0,0) -- (0,4.5); % график \draw [blue, thick, domain=0:2] plot (\x,2*\x); \draw [->, blue, thick] (-3.8,0)--(-0.05,0); \draw [<-, blue, thick] (2.05,0)--(4,0); \draw [blue, thick,dashed] (2,0)--(2,4); \draw [blue, thick,dashed] (0,4)--(2,4); % точки \draw[fill,blue] (2,4) circle [radius=0.03]; \draw[fill,blue] (0,4) circle [radius=0.03]; % подписи \node [below] at (0,0) {0}; \node [below] at (2,0) {1}; \node [left] at (0,4) {2}; \node [below right] at (4,0) {$p$}; \node [above left] at (0,4.3) {$f(p)$}; \end{tikzpicture} \end{center} \end{minipage} \end{figure} \subsection{Ещё пример рисунка} \begin{figure}[H] \begin{minipage}[H]{0.49\linewidth} \center Априорное распределение: \\[2.5ex] \begin{tikzpicture} % оси \draw [->] (-3.8,0) -- (4,0); \draw [->] (0,0) -- (0,3.5); % график \draw [blue, thick, domain=0:2] plot (\x, 2); \draw [->, blue, thick] (-3.8,0)--(-0.05,0); \draw [<-, blue, thick] (2.05,0)--(4,0); \draw [blue, thick,dashed] (2,0)--(2,2); % точки \draw[fill,blue] (2,2) circle [radius=0.03];f \draw[fill,blue] (0,2) circle [radius=0.03]; % подписи \node [below] at (0,0) {0}; \node [below] at (2,0) {1}; \node [left] at (0,2) {1}; \node [below right] at (4,0) {$p$}; \node [left] at (0,3.3) {$f(p)$}; \end{tikzpicture} \end{minipage} \hfill \begin{minipage}[H]{0.49\linewidth} \center Апостериорное распределение: \\[2.5ex] \begin{tikzpicture} % оси \draw [->] (-3.8,0) -- (3,0); \draw [->] (0,0) -- (0,3.5); % график12 \draw [blue, thick, domain=0:1] plot (\x, {12*\x*\x*(1-\x)}); \draw [blue, thick] (-3.8,0)--(0,0); \draw [blue, thick] (1,0)--(3,0); % подписи \node [below] at (0,0) {0}; \node [below] at (1,0) {1}; \node [below right] at (3,0) {$p$}; \node [left] at (0,3.3) {$f(p)$}; \end{tikzpicture} \end{minipage} \end{figure} \newpage \subsection{Tikztempaltes и их редактирование} % Пример взят отсюда! % http://www.texample.net/tikz/examples/is-lm-diagram/ \begin{figure}[h] \begin{center} \begin{tikzpicture}[ scale=2, IS/.style={blue, thick}, LM/.style={red, thick}, axis/.style={very thick, ->, >=stealth', line join=miter}, important line/.style={thick}, dashed line/.style={dashed, thin}, every node/.style={color=black}, dot/.style={circle,fill=black,minimum size=4pt,inner sep=0pt, outer sep=-1pt}, ] % axis \draw[axis,<->] (2.5,0) node(xline)[right] {$Y$} -| (0,2.5) node(yline)[above] {$i$}; % IS-LM diagram \draw[LM] (0.2,0.3) coordinate (LM_1) parabola (1.8,1.8) coordinate (LM_2) node[above] {\LM}; \draw[IS] (0.2,1.8) coordinate (IS_1) parabola[bend at end] (1.8,.3) coordinate (IS_2) node[right] {\IS}; %Intersection is calculated "manually" since Tikz does not offer %intersection calculation for parabolas \node[dot,label=above:$A$] at (1,.68) (int1) {}; %shifted IS-LM diagram \draw[xshift=.7cm, LM, red!52] (0.2,0.2) parabola (1.8,1.7) node[above] {\LM'}; \draw[xshift=.4cm, yshift=.3cm, IS, blue!60] (0.2,1.8) parabola[bend at end] (1.8,.3) node[right] {\IS'}; %Intersection of shifted IS-LM \path[xshift=.36cm, yshift=.35cm] (.98,.7) node[dot,label=above:{$B$}] (int2) {}; \path[xshift=.805cm] (1,.68) node[dot,label=above:$C$] (int3) {}; %arrows between intersections \draw[->, very thick, black, >=stealth'] ($(int1)+1/2*(-.80,1)$) -- ($(int2)+1/2*(-.8,1)$) node[sloped, above, midway] {$\mathsmaller{\Delta G > 0}$}; \draw[->, very thick, black, >=stealth'] ($(int2)+2*(.14,.2)$) -- ($(int2)!.2cm!270:(int2)+(.9,0)$) node[sloped,above, midway] {$\mathsmaller{\Delta M>0}$}; \begin{scope}[xshift=4cm] %E-diagram \draw[axis,<->] (0,2.5) node(eyline)[above] {$i$} |- (2.5,0) node(exline)[right] {$E$}; \draw[important line, green, xshift=.5cm] (.2,.2) coordinate (es) -- (1.5,1.5) coordinate (ee) node [above right] {Interest rate parity}; \end{scope} %Lines connecting IS LM coordinates and E coordinates \draw[dashed] let % Store the intersection point in \p1 for later retrieval. % A convenient feature of the let operation is that we can % access the x and y component of the coordinate directly % using the \x1 and \y1 syntax. \p1=(intersection of int2--[xshift=1]int2 and es--ee) in (0,\y1) node[left]{$i'$} -| (\x1,0) node[pos=0.5,dot,label=above:$B'$] {} node[below] {$E'$}; \draw[dashed line] let \p1=(intersection of int3--[xshift=1]int3 and es--ee) in (0,\y1) node[left]{$i\phantom{'}$} -| (\x1,0) node[dot,label=above:$C'$,pos=0.5] {} node[below] {$E$}; \end{tikzpicture} \end{center} \caption{Модель IS-LM } \end{figure} \newpage \subsection{Geogebra} % Магия geogebra! \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \draw[->,color=black] (-4.3,0.) -- (11.02,0.); \foreach \x in {-4.,-3.,-2.,-1.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.} \draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$}; \draw[->,color=black] (0.,-5.98) -- (0.,6.3); \foreach \y in {-5.,-4.,-3.,-2.,-1.,1.,2.,3.,4.,5.,6.} \draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$}; \draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$}; \clip(-4.3,-5.98) rectangle (11.02,6.3); \draw [line width=2.pt] (4.04,2.42) circle (2.2542404485768595cm); \draw [line width=2.pt] (-0.24,3.1)-- (7.6,0.6); \begin{scriptsize} \draw [fill=ududff] (4.04,2.42) circle (2.5pt); \draw[color=ududff] (4.18,2.79) node {$A$}; \draw [fill=ududff] (2.04,1.38) circle (2.5pt); \draw[color=ududff] (2.18,1.75) node {$B$}; \draw[color=black] (2.96,4.11) node {$c$}; \draw [fill=ududff] (-0.24,3.1) circle (2.5pt); \draw[color=ududff] (-0.1,3.47) node {$C$}; \draw [fill=ududff] (7.6,0.6) circle (2.5pt); \draw[color=ududff] (7.74,0.97) node {$D$}; \draw[color=black] (3.64,1.73) node {$f$}; \end{scriptsize} \end{tikzpicture} \begin{center} \definecolor{zzttqq}{rgb}{0.6,0.2,0.} \definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1.} \definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882} \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \draw [color=cqcqcq,, xstep=1.0cm,ystep=1.0cm] (2.02,-5.12) grid (19.58,6.7); \clip(2.02,-5.12) rectangle (19.58,6.7); \fill[line width=2.pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (5.06,3.3) -- (4.,-3.34) -- (16.02,1.48) -- cycle; \fill[line width=2.pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (7.,2.) -- (9.56,1.02) -- (9.42,4.46) -- cycle; \draw [line width=2.pt,color=zzttqq] (5.06,3.3)-- (4.,-3.34); \draw [line width=2.pt,color=zzttqq] (4.,-3.34)-- (16.02,1.48); \draw [line width=2.pt,color=zzttqq] (16.02,1.48)-- (5.06,3.3); \draw [line width=2.pt,color=zzttqq] (7.,2.)-- (9.56,1.02); \draw [line width=2.pt,color=zzttqq] (9.56,1.02)-- (9.42,4.46); \draw [line width=2.pt,color=zzttqq] (9.42,4.46)-- (7.,2.); \draw [line width=2.pt] (10.78,2.76) circle (3.0162891108114946cm); \begin{scriptsize} \draw [fill=ududff] (5.06,3.3) circle (2.5pt); \draw[color=ududff] (5.2,3.67) node {$A$}; \draw [fill=ududff] (4.,-3.34) circle (2.5pt); \draw[color=ududff] (4.14,-2.97) node {$B$}; \draw [fill=ududff] (16.02,1.48) circle (2.5pt); \draw[color=ududff] (16.16,1.85) node {$C$}; \draw[color=zzttqq] (4.26,0.21) node {$c$}; \draw[color=zzttqq] (10.18,-1.05) node {$a$}; \draw[color=zzttqq] (10.64,2.89) node {$b$}; \draw [fill=ududff] (7.,2.) circle (2.5pt); \draw[color=ududff] (7.14,2.37) node {$D$}; \draw [fill=ududff] (9.56,1.02) circle (2.5pt); \draw[color=ududff] (9.7,1.39) node {$E$}; \draw [fill=ududff] (9.42,4.46) circle (2.5pt); \draw[color=ududff] (9.56,4.83) node {$F$}; \draw[color=zzttqq] (8.22,1.39) node {$f$}; \draw[color=zzttqq] (9.86,2.93) node {$d$}; \draw[color=zzttqq] (8.04,3.63) node {$e$}; \draw [fill=ududff] (6.66,-1.4) circle (2.5pt); \draw[color=ududff] (6.8,-1.03) node {$G$}; \draw [fill=ududff] (13.52,3.66) circle (2.5pt); \draw[color=ududff] (13.66,4.03) node {$H$}; \draw [fill=ududff] (3.78,1.5) circle (2.5pt); \draw[color=ududff] (3.92,1.87) node {$I$}; \draw [fill=ududff] (10.78,2.76) circle (2.5pt); \draw[color=ududff] (10.92,3.13) node {$J$}; \draw [fill=ududff] (8.76,0.52) circle (2.5pt); \draw[color=ududff] (8.9,0.89) node {$K$}; \draw[color=black] (9.32,5.11) node {$g$}; \end{scriptsize} \end{tikzpicture} \end{center} \end{document} % конец документа