我使用 tikz 来表示斧头。代码如下:
\documentclass[a4paper,oneside,12pt]{article}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{trees}
\usepackage{relsize}
\usepackage{longtable,geometry}
\usepackage[frenchb]{babel}
\usepackage{wrapfig}
\usepackage{graphicx}
\geometry{dvips,a4paper,margin=1in}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[babel]{csquotes}
\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{decorations.text}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{decorations.fractals}
\usetikzlibrary{decorations.footprints}
\MakeAutoQuote{«}{»}
\pagestyle{headings}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw[thick,>=stealth,->] (0,0) node[below] {$-\infty$} -- (2.8,0) node[below]
{$\frac{\mathlarger{-e}}{\mathlarger{(1-\theta)}}-f$} node {$\bullet$} -- (5.6,0)
node[below] {$\frac{\mathlarger{-v}}{\mathlarger{(1-\theta)}}-f$} node {$\bullet$} --
(8.4,0) node[below] {$\frac{-2f-e-\sqrt{e^2-\frac{4ev}{1-\theta)}}}{2}$} node
{$\bullet$} -- (11.4,0) node[below] {$\frac{-2f-e+\sqrt{e^2-\frac{4ev}
{1-\theta)}}}{2}$} node {$\bullet$} -- (14.2,0) node[below] {$-f$} node{$\bullet$}--
(17,0) node[below] {$\omega(M)$} ;
\draw[color=black,decorate,decoration={brace, raise=0.8cm}]
(0,0) -- (5.57,0) node[above,pos=0.5] {E1};
\draw[color=black,decorate,decoration={brace, raise=0.8cm}]
(5.63,0) -- (8.37,0) node[above,pos=0.5] {E1, E2};
\draw[color=black,decorate,decoration={brace, raise=0.8cm}]
(8.43,0) -- (11.37,0) node[above,pos=0.5] {E1, E2, E3};
\draw[color=black,decorate,decoration={brace, raise=0.8cm}]
(11.43,0) -- (14.17,0) node[above,pos=0.5] {E1, E2};
\draw[color=black,decorate,decoration={brace, raise=0.8cm}]
(14.23,0) -- (16.7,0) node[above,pos=0.5] {E2};
\draw[color=red,decorate,decoration={brace, mirror, raise=1.5cm}]
(0,0) -- (2.77,0) node[below,pos=0.49] {E5};
\draw[color=red,decorate,decoration={brace, mirror, raise=1.5cm}]
(2.83,0) -- (17,0) node[below,pos=0.5] {E4};
\end{tikzpicture}
\end{center}
\end{document}
我如何移动文本 E4 和 E5 以使其更靠近红色括号?
提前致谢,如果布局不正确,请见谅。
答案1
该below
键采用可选的距离参数。below=1.6cm
在这种情况下,设置效果很好。
请注意,您不需要xcolors
明确加载包(这由完成tikz
)或decorations
库(它由特定的装饰库加载),并且您的代码中有很多此示例不需要的包。
\documentclass[a4paper,oneside,12pt]{article}
\usepackage{tikz}
\usepackage{relsize}
\usetikzlibrary{decorations.pathreplacing}
\pagestyle{headings}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw[thick,>=stealth,->] (0,0) node[below] {$-\infty$} -- (2.8,0) node[below]
{$\frac{\mathlarger{-e}}{\mathlarger{(1-\theta)}}-f$} node {$\bullet$} -- (5.6,0) node[below] {$\frac{\mathlarger{-v}}{\mathlarger{(1-\theta)}}-f$} node {$\bullet$} -- (8.4,0) node[below] {$\frac{-2f-e-\sqrt{e^2-\frac{4ev}{1-\theta)}}}{2}$} node {$\bullet$} -- (11.4,0) node[below] {$\frac{-2f-e+\sqrt{e^2-\frac{4ev}{1-\theta)}}}{2}$} node {$\bullet$} -- (14.2,0) node[below] {$-f$} node{$\bullet$}-- (17,0) node[below] {$\omega(M)$} ;
\draw[color=black,decorate,decoration={brace, raise=0.8cm}]
(0,0) -- (5.57,0) node[above=0.8cm,pos=0.5] {E1};
\draw[color=black,decorate,decoration={brace, raise=0.8cm}]
(5.63,0) -- (8.37,0) node[above=0.8cm,pos=0.5] {E1, E2};
\draw[color=black,decorate,decoration={brace, raise=0.8cm}]
(8.43,0) -- (11.37,0) node[above=0.8cm,pos=0.5] {E1, E2, E3};
\draw[color=black,decorate,decoration={brace, raise=0.8cm}]
(11.43,0) -- (14.17,0) node[above=0.8cm,pos=0.5] {E1, E2};
\draw[color=black,decorate,decoration={brace, raise=0.8cm}]
(14.23,0) -- (16.7,0) node[above=0.8cm,pos=0.5] {E2};
\draw[color=red,decorate,decoration={brace, mirror, raise=1.5cm}]
(0,0) -- (2.77,0) node[below=1.6cm,pos=0.49] {E5};
\draw[color=red,decorate,decoration={brace, mirror, raise=1.5cm}]
(2.83,0) -- (17,0) node[below=1.6cm,pos=0.5] {E4};
\end{tikzpicture}
\end{center}
\end{document}
答案2
您可以添加一点风格!(我采用了 Jake 的精彩答案的代码)
备注:(a)--节点{x}(b);默认pos = .5更新:很多节点使用below
所以我修改了every node/.style
但为了调整其他节点,我创建了ce/.style={anchor=center}
。below
是与相同的选项anchor=south
。
\begin{tikzpicture}[bst/.style={color=black,decorate,decoration={brace, raise=0.8cm}},
rst/.style={color=red,decorate,decoration={brace,mirror, raise=1.5cm}},
eti/.style={above=0.8cm},
every node/.style=below,
ce/.style={anchor=center}]
\draw[thick,>=stealth,->] (0,0)
node {$-\infty$} -- (2.8,0) node {$\frac{\mathlarger{-e}}{\mathlarger{(1-\theta)}}-f$}
node[ce] {$\bullet$} -- (5.6,0) node {$\frac{\mathlarger{-v}}{\mathlarger{(1-\theta)}}-f$}
node[ce] {$\bullet$} -- (8.4,0) node {$\frac{-2f-e-\sqrt{e^2-\frac{4ev}{1-\theta)}}}{2}$}
node[ce] {$\bullet$} -- (11.4,0) node {$\frac{-2f-e+\sqrt{e^2-\frac{4ev}{1-\theta)}}}{2}$}
node[ce] {$\bullet$} -- (14.2,0) node {$-f$}
node[ce] {$\bullet$} -- (17,0) node {$\omega(M)$} ;
\draw[bst] (0,0) -- node[eti] {E1} (5.57 ,0) ;
\draw[bst] (5.63,0) -- node[eti] {E1, E2} (8.37 ,0) ;
\draw[bst] (8.43,0) -- node[eti] {E1, E2, E3} (11.37,0) ;
\draw[bst] (11.43,0) -- node[eti] {E1, E2} (14.17,0) ;
\draw[bst] (14.23,0) -- node[eti] {E2} (16.7 ,0) ;
\draw[rst] (0,0) -- node[below=1.6cm] {E5} (2.77 ,0) ;
\draw[rst] (2.83,0) -- node[below=1.6cm] {E4} (17 ,0) ;
\end{tikzpicture}