0

I use a LaTeX template for Xournal++

% This template avoids the scontents package, which is only available on relatively recent TeX distributions
\documentclass[varwidth=true, crop, border=5pt]{standalone}

% Packages
\usepackage{amsmath}
\usepackage{amssymb}

% Blank formula checking
\usepackage{ifthen}
\newlength{\pheight}

% Color support
\usepackage{xcolor}
\definecolor{xpp_font_color}{HTML}{%%XPP_TEXT_COLOR%%}

% User input
\def\preview{\( 
    \displaystyle
    %%XPP_TOOL_INPUT%%
    \)%
}

\begin{document}
  % Check if the formula is empty
  \settoheight{\pheight}{\preview}
  \ifthenelse{\pheight=0}{\GenericError{}{xournalpp:blankformula}{}{}}
\newcommandx{\graph}[3][1=,2=]{
    \begin{tikzpicture}[scale=.5]
        \begin{axis}[xlabel=$x$,ylabel=$y$, axis lines=center,samples=100, #2]
            \addplot[#1]{ #3 };
            
        \end{axis}
    \end{tikzpicture}
}
  % Render the user input
  \textcolor{xpp_font_color}{\preview}
\end{document}

An output of above command is:

But I want to edit above command $\graph$ such that the output graph could look like in this picture and support multiple functions on the same chart and domain of x,y just be zero or postive values:

enter image description here

How can we edit above command in order for the output to look like the above picture, while adding support for any number of functions? Thank you for your help.

4
  • Can you please add an example of how you're calling the \graph command?
    – egreg
    Commented Mar 27, 2022 at 13:08
  • @egreg I added it.
    – tstt
    Commented Mar 27, 2022 at 13:55
  • OK, but what about the optional arguments?
    – egreg
    Commented Mar 27, 2022 at 13:58
  • We can igonre optional arguments and just consider postive x, and y for any function.
    – tstt
    Commented Mar 27, 2022 at 14:15

0

You must log in to answer this question.

Browse other questions tagged .