所以我在网上找到了一个如何创建特定图形(tikzpicture)的示例。现在我已经在 latex 中创建了图形,但不知何故我的标题和部分文本不会显示。我猜这是因为我没有 article 的文档类。但如果我的文档类是 article,则图形不会显示。我该如何解决这个问题?下面是我的代码。
\documentclass[tikz,border=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{verbatim}
\usetikzlibrary{calc}
\title{Matematisk modellering}
\author{olba_ }
\date{February 2016}
\begin{document}
\maketitle
\section{Introduction}
\section{Problem 1}
Givet avståndet $d$ från högtalare och ljudkälla, samt givet högtalarnas positioner, beräkna läget för ljudkällan.
\begin{tikzpicture}
[
scale=3,
>=stealth,
point/.style = {draw, circle, fill = black, inner sep = 1pt},
dot/.style = {draw, circle, fill = black, inner sep = .2pt},
]
% the circle
\def\rad{1}
\node (origin) at (0,0) {};
% triangle nodes: just points on the circle
\node (n0) at +(60:\rad) [point, label = above:$s$] {};
\node (n1) at +(-145:\rad) [point, label = below:$r_{1}$] {};
\node (n2) at +(-45:\rad) [point, label = {below right:$r_{2}$}] {};
\node (n3) at +(10:\rad) [point, label = {below left:$r_{3}$}] {};
% triangle edges: connect the vertices, and leave a node at the midpoint
\draw[->] (n2) -- node (a) [label = {above left:$d_{2}$}] {} (n0);
\draw[->] (n1) -- node (b) [label = {below right:$d_{1}$}] {} (n0);
\draw[->] (n3) -- node (c) [label = {above right:$d_{3}$}] {} (n0);
\end{tikzpicture}
\end{document}
答案1
我猜你想写一篇真正的文章,包括标题等等。所以先使用类article
,然后再加载tikz
。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{calc}
\title{Matematisk modellering}
\author{name here}
\date{February 2016}
\begin{document}
\maketitle
\section{Introduction}
\section{Problem 1}
Givet avståndet $d$ från högtalare och ljudkälla, samt givet högtalarnas positioner, beräkna läget för ljudkällan.
\begin{figure*}[h]\centering
\begin{tikzpicture}
[
scale=3,
>=stealth,
point/.style = {draw, circle, fill = black, inner sep = 1pt},
dot/.style = {draw, circle, fill = black, inner sep = .2pt},
]
% the circle
\def\rad{1}
\node (origin) at (0,0) {};
% triangle nodes: just points on the circle
\node (n0) at +(60:\rad) [point, label = above:$s$] {};
\node (n1) at +(-145:\rad) [point, label = below:$r_{1}$] {};
\node (n2) at +(-45:\rad) [point, label = {below right:$r_{2}$}] {};
\node (n3) at +(10:\rad) [point, label = {below left:$r_{3}$}] {};
% triangle edges: connect the vertices, and leave a node at the midpoint
\draw[->] (n2) -- node (a) [label = {above left:$d_{2}$}] {} (n0);
\draw[->] (n1) -- node (b) [label = {below right:$d_{1}$}] {} (n0);
\draw[->] (n3) -- node (c) [label = {above right:$d_{3}$}] {} (n0);
\end{tikzpicture}
\end{figure*}
\end{document}