凭证预算约束tikz

时间:2018-01-24 22:14:58

标签: latex tikz economics

我从超级实用指南(from this link)中获取了以下代码,并在TeXstudio中运行。

 [domain=0:5,range=4:5,scale=1,thick]
    \usetikzlibrary{calc}%all
    %Definelinearparametersforsupplyanddemand
    \def\inc{62}%Entertotalincome
    \def\pa{19.5}%Priceofx1
    \def\pb{10}%Priceofx2.
    \def\panew{10.6}
    \def\ica{\x,{2/\x−20}}
    \def\icb{\x,{\sslp∗\x+\sint}}
    \def\bcv{\x,{(−\pa)/(\pb)∗\x+(\inc)/(\pb)}}
    \def\bcx{\x,{(5)/\x}}

    %Definecoordinates.
    \coordinate(x2)at(0,{\inc/\pb});
    \coordinate(x1)at({\inc/\pa},0);
    \coordinate(x1’)at({\inc/\panew},0);
    %Drawaxes,anddottedequilibriumlines.
    \draw[->](0,0)(6.2,0)node[right]{$x1$};
    \draw[->](0,0)(0,6.2)node[above]{$x2$};
    \draw[dashed](1.2,3.9)(0,3.9)node[left]{voucher};
    \draw[thick,domain=1.2;\inc/\pa]plot(\bcv)node[below]{BudgetConstraint};
    \draw[thick,color=purple,domain=1:5]plot(\bcx)node[below]{Indiff.Curve};

应该看起来像:

Voucher Treatment

但是我收到了错误:

Paragraph ended before \tikz@plot@samples@recalc was complete.

有一整套错误消息:

Paragraph ended before \tikz@plot@samples@recalc was complete.
Something's wrong--perhaps a missing \item. \subsection
Something's wrong--perhaps a missing \item. \subsection
Something's wrong--perhaps a missing \item. \subsection
Something's wrong--perhaps a missing \item. \subsection
Something's wrong--perhaps a missing \item. \subsubsection
Something's wrong--perhaps a missing \item. \subsubsection
Missing \endgroup inserted. \end{figure}
Missing \endgroup inserted. \end{figure}
Missing \endgroup inserted. \end{figure}
Missing \endgroup inserted. \end{figure}
Missing \endgroup inserted. \end{figure}
Missing } inserted. \end{figure}
Missing \endgroup inserted. \end{figure}
Missing \endgroup inserted. \end{figure}
Missing \endgroup inserted. \end{figure}
Missing } inserted. \end{figure}
Undefined control sequence. \end{figure}
Missing number, treated as zero. \end{figure}
\begin{tikzpicture} on input line 111 ended by \end{figure}. \end{figure}
\begin{tikzpicture} on input line 111 ended by \end{document}. \end{document}
running in backwards compatibility mode (unsuitable tick labels; missing features). Consider writing \pgfplotsset{compat=1.15} into your preamble.
wrapfigure used inside a conflicting environment
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float
Stationary wrapfigure forced to float

有什么建议吗?这是完整的.tex代码:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Simple Sectioned Essay Template
% LaTeX Template
%
% This template has been downloaded from:
% http://www.latextemplates.com
%
% Note:
% The \lipsum[#] commands throughout this template generate dummy text
% to fill the template out. These commands should all be removed when 
% writing essay content.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[12pt]{article} % Default font size is 12pt, it can be changed here

\usepackage{geometry} % Required to change the page size to A4
\geometry{a4paper} % Set the page size to be A4 as opposed to the default US Letter

\usepackage{graphicx} % Required for including pictures

\usepackage{float} % Allows putting an [H] in \begin{figure} to specify the exact location of the figure
\usepackage{wrapfig} % Allows in-line images such as the example fish picture]
\usepackage{mathtools}
\usepackage{pgfplots}

\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template

\linespread{1.2} % Line spacing

%\setlength\parindent{0pt} % Uncomment to remove all indentation from paragraphs

\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored

\begin{document}

%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------

\begin{titlepage}

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % Defines a new command for the horizontal lines, change thickness here

\center % Center everything on the page

\textsc{\Large University of Oxford}\\[1.5cm] % Name of your university/college
\textsc{\large Final Honours School of Philosophy, Politics \& Economics}\\[0.5cm] % Major heading such as course name
\textsc{\large Behavioural \& Experimental Economics}\\[1.5cm] % Minor heading such as course title

\HRule \\[0.6cm]
{ \Large \bfseries Mental Accounting \& Donations}\\[0.3cm] % Title of your document
\HRule \\[3cm]

\begin{minipage}{0.4\textwidth}
\begin{flushleft} \large
\emph{Author:}\\
Marcus \textsc{Ashby} % Your name
\end{flushleft}
\end{minipage}
~
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{Supervisor:} \\
Prof. Johannes \textsc{Abeler} % Supervisor's Name
\end{flushright}
\end{minipage}\\[4cm]

{\large \today}\\[3cm] % Date, change the \today to a set date if you want to be precise

%\includegraphics{Logo}\\[1cm] % Include a department/university logo - this will require the graphicx package

\vfill % Fill the rest of the page with whitespace

\end{titlepage}

%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------
 % Include a table of contents
\begin{abstract}
Mental accounting, a form of bounded rationality, is an influential theory of microeconomic behaviour. It has only recently been shown to play a significant role in distorting private consumption decisions and its predictions are strong. Fieldwork has shown that consumers experience inframarginal in-kind donations as distortionary, which violates the predictions of the standard model. This paper extends applies this body of research to private donations. Integrating the two literatures, I test whether mental accounting is a neglected alternative to ‘warm glow’ in explaining patterns of private donation which deviate from a model of pure altruism. A randomised controlled trial run on undergraduate students provides new evidence that mental accounting is responsible for this pattern of donation.
\end{abstract}
\newpage % Begins the essay on a new page instead of on the same page as the table of contents 

%----------------------------------------------------------------------------------------
%   INTRODUCTION
%----------------------------------------------------------------------------------------

\section{Introduction} % Major section
Here is an indifference curve that I might use:
\begin{quote}
\begin{tikzpicture}
\begin{axis}[
axis x line=bottom,
axis y line=left,
xmin=0, xmax=10, 
ymin=0, ymax=10,
xlabel={$y_r$},
ylabel={$y_d$},
ytick=\empty,
xtick={0},
]
\draw (axis cs:2.2,9.5) to [bend right=40] coordinate[pos=0.2] (l_i) (axis cs:8,2);
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}[domain=0:5,range=4:5,scale=1,thick]
\usetikzlibrary{calc}%all
%Definelinearparametersforsupplyanddemand
\def\inc{62}%Entertotalincome
\def\pa{19.5}%Priceofx1
\def\pb{10}%Priceofx2.
\def\panew{10.6}
\def\ica{\x,{2/\x−20}}
\def\icb{\x,{\sslp∗\x+\sint}}
\def\bcv{\x,{(−\pa)/(\pb)∗\x+(\inc)/(\pb)}}
\def\bcx{\x,{(5)/\x}}

%Definecoordinates.
\coordinate(x2)at(0,{\inc/\pb});
\coordinate(x1)at({\inc/\pa},0);
\coordinate(x1’)at({\inc/\panew},0);
%Drawaxes,anddottedequilibriumlines.
    \draw[->](0,0)(6.2,0)node[right]{$x1$};
    \draw[->](0,0)(0,6.2)node[above]{$x2$};
    \draw[dashed](1.2,3.9)(0,3.9)node[left]{voucher};
    \draw[thick,domain=1.2;\inc/\pa]plot(\bcv)node[below]{BudgetConstraint};
    \draw[thick,color=purple,domain=1:5]plot(\bcx)node[below]{Indiff.Curve};

\end{tikzpicture}

%------------------------------------------------

\subsection{Subsection 1} % Sub-section

\lipsum[1] % Dummy text

%------------------------------------------------

\subsection{Subsection 2} % Sub-section

\lipsum[2] % Dummy text

%------------------------------------------------

\subsubsection{Subsubsection 1} % Sub-sub-section

\lipsum[3] % Dummy text

\begin{figure}[H] % Example image
\center{\includegraphics[width=0.5\linewidth]{placeholder}}
\caption{Example image.}
\label{fig:speciation}
\end{figure}

%------------------------------------------------

\subsubsection{Subsubsection 2} % Sub-sub-section

\lipsum[4] % Dummy text

%----------------------------------------------------------------------------------------
%   MAJOR SECTION 1
%----------------------------------------------------------------------------------------

\section{Content Section} % Major section

\lipsum[5] % Dummy text

%------------------------------------------------

\subsection{Subsection 1} % Sub-section

\subsubsection{Subsubsection 1} % Sub-sub-section

\lipsum[6] % Dummy text

%------------------------------------------------

\subsubsection{Subsubsection 2} % Sub-sub-section

\lipsum[6] % Dummy text
\begin{wrapfigure}{l}{0.4\textwidth} % Inline image example
  \begin{center}
    \includegraphics[width=0.38\textwidth]{fish}
  \end{center}
  \caption{Fish}
\end{wrapfigure}
\lipsum[7-8] % Dummy text

%------------------------------------------------

\subsubsection{Subsubsection 3} % Sub-sub-section

\begin{description} % Numbered list example

\item[First] \hfill \\
\lipsum[9] % Dummy text

\item[Second] \hfill \\
\lipsum[10] % Dummy text

\item[Third] \hfill \\
\lipsum[11] % Dummy text

\end{description} 

%----------------------------------------------------------------------------------------
%   MAJOR SECTION X - TEMPLATE - UNCOMMENT AND FILL IN
%----------------------------------------------------------------------------------------

%\section{Content Section}

%\subsection{Subsection 1} % Sub-section

% Content

%------------------------------------------------

%\subsection{Subsection 2} % Sub-section

% Content

%----------------------------------------------------------------------------------------
%   CONCLUSION
%----------------------------------------------------------------------------------------

\section{Conclusion} % Major section

\lipsum[12-13]

%----------------------------------------------------------------------------------------
%   BIBLIOGRAPHY
%----------------------------------------------------------------------------------------

\begin{thebibliography}{99} % Bibliography - this is intentionally simple in this template

\bibitem[Figueredo and Wolf, 2009]{Figueredo:2009dg}
Figueredo, A.~J. and Wolf, P. S.~A. (2009).
\newblock Assortative pairing and life history strategy - a cross-cultural
  study.
\newblock {\em Human Nature}, 20:317--330.

\end{thebibliography}

%----------------------------------------------------------------------------------------

\end{document}

1 个答案:

答案 0 :(得分:1)

您的文档存在以下问题:

  • 我需要将<!-- #region Jssor Slider Begin --> <!-- Generator: Jssor Slider Maker --> <!-- Source: https://www.jssor.com --> <script src="js/jssor.slider-26.9.0.min.js" type="text/javascript"></script> <script type="text/javascript"> jssor_1_slider_init = function() { var jssor_1_SlideshowTransitions = [ {$Duration:800,$Opacity:2} ]; var jssor_1_options = { $AutoPlay: 1, $Cols: 1, $Align: 0, $SlideshowOptions: { $Class: $JssorSlideshowRunner$, $Transitions: jssor_1_SlideshowTransitions, $TransitionsOrder: 1 }, $ArrowNavigatorOptions: { $Class: $JssorArrowNavigator$ }, $BulletNavigatorOptions: { $Class: $JssorBulletNavigator$ } }; var jssor_1_slider = new $JssorSlider$("jssor_1", jssor_1_options); /*#region responsive code begin*/ var MAX_WIDTH = 980; function ScaleSlider() { var containerElement = jssor_1_slider.$Elmt.parentNode; var containerWidth = containerElement.clientWidth; if (containerWidth) { var expectedWidth = Math.min(MAX_WIDTH || containerWidth, containerWidth); jssor_1_slider.$ScaleWidth(expectedWidth); } else { window.setTimeout(ScaleSlider, 30); } } ScaleSlider(); $Jssor$.$AddEvent(window, "load", ScaleSlider); $Jssor$.$AddEvent(window, "resize", ScaleSlider); $Jssor$.$AddEvent(window, "orientationchange", ScaleSlider); /*#endregion responsive code end*/ }; </script> <style> /* jssor slider loading skin spin css */ .jssorl-009-spin img { animation-name: jssorl-009-spin; animation-duration: 1.6s; animation-iteration-count: infinite; animation-timing-function: linear; } @keyframes jssorl-009-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .jssorb051 .i {position:absolute;cursor:pointer;} .jssorb051 .i .b {fill:#fff;fill-opacity:0.5;} .jssorb051 .i:hover .b {fill-opacity:.7;} .jssorb051 .iav .b {fill-opacity: 1;} .jssorb051 .i.idn {opacity:.3;} .jssora051 {display:block;position:absolute;cursor:pointer;} .jssora051 .a {fill:none;stroke:#fff;stroke-width:360;stroke-miterlimit:10;} .jssora051:hover {opacity:.8;} .jssora051.jssora051dn {opacity:.5;} .jssora051.jssora051ds {opacity:.3;pointer-events:none;} </style> <div id="jssor_1" style="position:relative;margin:0 auto;top:0px;left:0px;width:980px;height:380px;overflow:hidden;visibility:hidden;"> <!-- Loading Screen --> <div data-u="loading" class="jssorl-009-spin" style="position:absolute;top:0px;left:0px;width:100%;height:100%;text-align:center;background-color:rgba(0,0,0,0.7);"> <img style="margin-top:-19px;position:relative;top:50%;width:38px;height:38px;" src="img/spin.svg" /> </div> <div data-u="slides" style="cursor:default;position:relative;top:0px;left:0px;width:980px;height:380px;overflow:hidden;"> <div data-p="170.00"> <img data-u="image" src="img/001.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/002.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/003.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/004.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/005.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/006.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/007.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/008.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/009.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/010.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/011.jpg" /> </div> <div data-p="170.00"> <img data-u="image" src="img/012.jpg" /> </div> </div> <!-- Bullet Navigator --> <div data-u="navigator" class="jssorb051" style="position:absolute;bottom:12px;right:12px;" data-autocenter="1" data-scale="0.5" data-scale-bottom="0.75"> <div data-u="prototype" class="i" style="width:16px;height:16px;"> <svg viewbox="0 0 16000 16000" style="position:absolute;top:0;left:0;width:100%;height:100%;"> <circle class="b" cx="8000" cy="8000" r="5800"></circle> </svg> </div> </div> <!-- Arrow Navigator --> <div data-u="arrowleft" class="jssora051" style="width:55px;height:55px;top:0px;left:25px;" data-autocenter="2" data-scale="0.75" data-scale-left="0.75"> <svg viewbox="0 0 16000 16000" style="position:absolute;top:0;left:0;width:100%;height:100%;"> <polyline class="a" points="11040,1920 4960,8000 11040,14080 "></polyline> </svg> </div> <div data-u="arrowright" class="jssora051" style="width:55px;height:55px;top:0px;right:25px;" data-autocenter="2" data-scale="0.75" data-scale-right="0.75"> <svg viewbox="0 0 16000 16000" style="position:absolute;top:0;left:0;width:100%;height:100%;"> <polyline class="a" points="4960,1920 11040,8000 4960,14080 "></polyline> </svg> </div> </div> <script type="text/javascript">jssor_1_slider_init();</script> 中的单引号替换为正确的 ASCII单引号\coordinate(x1’)at({\inc/\panew},0);
  • 域间隔 \coordinate(x1')at({\inc/\panew},0);而不是;: - &gt; \draw[thick,domain=1.2;\inc/\pa]plot(\bcv)node[below]{BudgetConstraint};
  • 您的 \draw[thick,domain=1.2:\inc/\pa]plot(\bcv)node[below]{BudgetConstraint}; 永远不会关闭。

修复这些问题后,文档会成功编译(如果您有合适的图像)。这是一个片段:

enter image description here