LaTeX file used verbatimi within Moodle?

LaTeX file used verbatimi within Moodle?

by Davide Cervone -
Number of replies: 17
In another discussion, Francesco Passarini asks:
i have a problem. i can write mathematic lines using the double $ and using the tex language but now i need to do another thing.

i have to make a document which contain both latex expressions and somelines of natural language (english).

i thought to use a latex file and riproduce it on the text editor of moodle, but the tex file contain other tag (not double $) and it include also other file which allow latex to work better and which i can use on a latex editor.

example:

"\documentclass[12pt,italian]{article} 
\usepackage[italian]{babel} 
\usepackage[latin1]{inputenc} 
\usepackage{euro}

[...]

\probmax{x_1, x_2}{2x_1 + x_2} 
{x_2 \leq 10 \\2x_1 + 5x_2 \leq 60 \\ 
x_1 + x_2 \leq  18 \\ 
3x_1 + x_2 \leq 44\\ x_1 \geq 0, x_2 \geq 0}. 
\item (HL 3.1-6)"
my question is:

"how can i riproduce a tex file in moodle? where can i write the double $ on the file? is it possible include some files of latex into the filter folder for using them on the text editor of moodle like a latex editor?"

thank you Davide

I am moving the question here in order to start a new thread, since the previous one was already getting long and the question no longer related to the original topic of that thread.

Davide

Average of ratings: -
In reply to Davide Cervone

Re: LaTeX file used verbatimi within Moodle?

by Davide Cervone -
I'm not sure I fully understand the issue you are trying to get at. Are you asking how to include a TeX file verbatim within a Moodle document? If so, there is no way to do that. Neither jsMath nor mimeTeX (which underlies the TeX filter) implements ALL of TeX, only the mathematical portion of it. The rest of the page layout is supposed to be handled through HTML. In the case of Moodle, this is either provided by the WYSIWYG editor, or by one of several formats in which you can hand type your messages (see the "Formatting" menu below the textarea where you type your messages if you are not using the HTML editor -- you can turn it off in your Moodle preference page if you want).

So if you are looking to simply cut and paste a full TeX document into Moodle, you will not be able to do that. For instance, in your example, the \documentclass and \usepackage commands will not be processed and are not needed. Other non-math TeX command, like {\it italics}, would have to be converted to something like <I>italics</I>, depending on which format you are using. I don't use the WYSIWYG editor myself, but I suspect you would need to select the text and hit the "italic" button for that, so all the changes would have to be made by hand. Similarly, the \item would have to be changed to one of the HTML list formats.

One of the problems you will face is that the code you list above uses non-standard macros, like \probmax, and so neither jsMath nor mimeTeX will process that directly. JsMath does provide the \def and \newcommand macros, so if the definition of \probmax is not too complicated, you might be able to define this macro for use within jsMath yourself. You would have to put the definition within dollar signs at the top of each document that uses it, or you could arrange for a local customization file to be loaded automatically along with jsMath that would include the definition (I described how to do that in another post). Then you would put the \probmax call within dollar signs so that jsMath would process it.

If you have a lot of these and hand conversion would be too time-consuming, you might be able to use one of the TeX-to-HTML translators to first convert your source LaTeX file to HTML and then paste that into Moodle (using HTML format). For example, I understand that tex4ht has a jsMath output mode, so that might work for you. I've never used it, so don't know how well that will suit your needs.

I hope that answers your question. I'm afraid that you will have some conversion to do before you can use your existing files within Moodle.

Davide
In reply to Davide Cervone

Re: LaTeX file used verbatimi within Moodle?

by Dan Stowell -
Just to add to this - it's not possible to include a LaTeX file verbatim, but it is possible to include a HTML file verbatim of course. Use a tool like latex2html to convert the files and then just load them into your course. Should be easy to do.
In reply to Dan Stowell

Re: LaTeX file used verbatimi within Moodle?

by Davide Cervone -
I suggested that as well, but you do have to be a bit careful with this. If you use latex2html to produce an HTML file that uses images to represent the mathematics, then you would have to make those images available as well, and it would be a pain to move them all and you'd probably also need to change the references to their URLs once you know where they ended up in the Moodle storage area. That's why I suggested tex4ht, which has a jsMath output mode (rather than images), so there would be no problem pasting the result into Moodle.

One issue that might arise, however, is whether the converter uses an external style file to control the layout. If the HTML file calls on external files, you might have to handle that more carefully when it is pasted into Moodle. So converters can certainly help, but there definitely are issues to be dealt with there as well. (Your statement "it is possible to include a HTML file verbatim" is not quite true, as you can only enter the BODY of an HTML file, not the HEAD, into Moodle. That can make a difference in this case.)

Davide
In reply to Davide Cervone

Re: LaTeX file used verbatimi within Moodle?

by Francesco Passarini -

thank you Davide ad Dan,

you answered so well to my question. i know how to work now.

another thing:

the function probmax was written by my teacher and saved in a file which is included into the latex package, so when my teacher use his latex editor he can use this function.

so if i want to use this file to write mathematic lines in Moodle what i have to do? do you think this file is compatible with jsMath? 

maybe i have to define a new file like you explained on the other discussion copying the code of the file of my teacher but i don't know if i'm so able now.

what do you think davide?

thank you again 

In reply to Francesco Passarini

Re: LaTeX file used verbatimi within Moodle?

by Davide Cervone -
If you can post the definition of \probmax (the \def or \newcommand command that defines \probmax, and any other non-standard macros that it uses), I'll be able to give you better advice. Since jsMath only implements the mathematical commands, and not all of TeX's internal commands, deciding whether jsMath can handle it depends on what it does. For example, if it uses \if statements or other TeX flow-control commands, it would not work directly. But if it is just inserting its arguments into a template for the problem, then chances are that will work fine. Some changes will probably need to be made, however, since it looks like the macro initiates math mode internally, and but you will need to have it run in math mode to start with in order to get jsMath to process it.

So post the code and we'll go from there.

Davide
In reply to Davide Cervone

Re: LaTeX file used verbatimi within Moodle?

by Francesco Passarini -

hi davide, i'm copying the code which define the \probmax function.

but this function is a mathematic one, it's made up to write better mathematic problem in a particular form....so it's a mathematic command, not other latex commands.

this is the code:

%
%  PREAMBLE.TEX
%  written by RDL
%  version 2.0
%  last modified  October 8, 1998
%
\def\fileversion{2.1}
\def\filedate{1998/11/15}
\wlog{LaTeX `preamble'  \fileversion\space<\filedate> (RDL)}
\typeout{LaTeX `preamble'  \fileversion\space<\filedate> (RDL)}
\makeatletter


%
%  shortcut definition
%

\newcommand{\lineitem}[1]{\item[#1]\mbox{}}
\newcommand{\oneto}[1]{1, \ldots, {#1}}
\newcommand{\dst}{\displaystyle}
\newcommand{\ie}{i.e., }
\newcommand{\POW}{Piece-Of-Work }
\newcommand{\POWs}{Piece-Of-Works }
\newcommand{\RHS}{right--hand-side}
\newcommand{\LHS}{left--hand-side}


%
% roman text in mathmode commands
%

\newcommand{\insmat}[1]{\mathop{\mbox{\rm #1}}}  % for mathmode
                                                   %(with underlines)
\newcommand{\inmat}[1]{\mbox{\rm {#1}}}            % roman text in mathmode
\def\1{{\mathchoice {\roman {1\mskip-4mu l}} {\roman {1\mskip-4mu l}}
{\roman {1\mskip-4.5mu l}} {\roman {1\mskip-5mu l}}}}

 

 

 

%
% common definitions needed
%

\newcommand{\geeq}{ {  {{}\atop{>}}\atop{{=}\atop{}}}}
\newcommand{\leeq}{ {  {{}\atop{<}}\atop{{=}\atop{}}}}
\newcommand{\infinity}{\infty}
%\newcommand{\ip}[2]{\left\langle #1,#2 \right\rangle}
\newcommand{\ip}[2]{{#1}^T{#2}}
\newcommand{\inv}[1]{#1^{-1}}
\newcommand{\norm}[1]{\left\| #1 \right\|}
\newcommand{\pnorm}[2]{\norm{#1}_#2}
\newcommand{\pop}[1]{P_{#1}}
\newcommand{\ppop}[2]{P_{#2,#1}}
\newcommand{\pproj}[3]{P_{#2,#1}(#3)}
\newcommand{\proj}[2]{\pop{#1}(#2)}
\newcommand{\modulus}[1]{\left| #1 \right|}
\newcommand{\set}[2]{\left\{ #1 \mid #2 \right\}}
\newcommand{\seq}[1]{\left\{ #1 \right\}}
\newcommand{\goes}{\rightarrow}
\newcommand{\nin}{\in\hspace*{-1.8ex}/\hspace*{1.0ex}}
\newcommand{\abs}[1]{\left | #1 \right |}
\newcommand{\der}{\nabla}
\@ifundefined{grad}
{
\newcommand{\grad}{\nabla}
}{}
\newcommand{\half}{\frac{1}{2}}
\newcommand{\intsect}{\bigcap}
\newcommand{\summ}[2]{\sum_{#1}^{#2}}
\newcommand{\union}{\cup}
\newcommand{\define}{:=}
\newcommand{\ldef}{:=}
%\newcommand{\ldef}{\mathrel{\raise.095ex\hbox{:}\mkern-4.2mu=}}
%\newcommand{\ldef}{\stackrel{\mathrm{def}}{=}}
\newcommand{\rdef}{=:}
\newcommand{\msp}{\;\;}
\newcommand{\floor}[1]{\lfloor{#1}\rfloor}
\newcommand{\ceil}[1]{\lceil{#1}\rceil}
\newcommand\refe[1]{(\ref{#1})}


%
% common number system
%
\@ifundefined {flalign}
{
   \newcommand{\real}[1]{{\mathrm I\!R}^{#1}}
   \def\C{{\mathrm\;\rule{.1em}{1.55ex}\!\!C}}
   \def\R{\inmat{\rm I}\!\inmat{\rm R}}
   \def\Q{{\mathrm\;\rule{.1em}{1.55ex}\!\!Q}}
   \def\Z{{{\mathrm Z}\!\!{\mathrm Z}}}
   \def\N{\inmat{\mathrm I}\!\inmat{\mathrm N}}
}
{
    \newcommand{\field}[1]{\mathbb #1}
    \def\C{\field{C}}
    \def\R{\field{R}}
    \def\Q{\field{Q}}
    \def\Z{\field{Z}}
    \def\N{\field{N}}
}
\def\reals{\openR}
\def\integers{\openN}
\def\Fm{\openF^m}
\def\Fn{\openF^n}
\def\Rm{\openR^m}
\def\Rl{\openR^l}
\def\Rn{\openR^n}
\def\Rd{\openR^d}
\def\Rs{\openR^s}
\def\Cs{\openC^s}
\def\Rmn{\openR^{m\times n}}
\def\Rnm{\openR^{n\times m}}
\def\Zm{\openZ^m}
\def\Zn{\openZ^n}
\def\Zd{\openZ^d}
\def\Zs{\openZ^s}


%
% misc
%

\def\setstretch#1{\renewcommand{\baselinestretch}{#1}}


\def\suchthat{\hbox{\mathrm\ s.t.\ }}
\def\cond{\mathop{\mathrm cond}}
\def\vol{\mathop{\mathrm vol}}
\def\dom{\mathop{\mathrm dom}}
\def\ran{\mathop{\mathrm ran}}
\def\tar{\mathop{\mathrm tar}}
\def\jump{\mathop{\mathrm jump}}
\def\for{\mathop{\mathrm for}}
\def\all{\mathop{\mathrm all}}
% note: since  \span  is a plain TeX operator, use something else here
\def\diam{\mathop{\mathrm diam}}
\def\signum{\mathop{\mathrm signum}}
\def\area{\mathop{\mathrm area}}
\def\const{{\mathrm const}{}}
\def\supp{\mathop{\mathrm supp}}
\def\meas{\mathop{\mathrm meas}}
\def\boldA{{{\bf A}}}
\def\boldB{{{\bf B}}}
\def\boldC{{{\bf C}}}
\def\boldK{{{\bf K}}}
\def\boldL{{{\bf L}}}
\def\boldO{{{\bf O}}}
\def\cA{\mathcal A}
\def\cB{\mathcal B}
\def\cD{\mathcal D}
\def\cF{\mathcal F}
\def\cZ{\mathcal Z}
\def\cN{\mathcal N}
\def\cM{\mathcal M}
\def\cK{\mathcal K}
\def\openA{{{\mathrm A}\kern-.63em{\mathrm A}}}
\def\openB{{{\mathrm I}\kern-.16em {\mathrm B}}}
\def\openC{{\mathrm C\kern-.18cm\vrule width.6pt height 6pt depth-.2pt \kern.18cm}}
\def\openD{{{\mathrm I}\kern-.16em {\mathrm D}}}
\def\openF{{{\mathrm I}\kern-.16em {\mathrm F}}}
\def\openI{{{\mathrm I}\kern-.2em {\mathrm I}}}
\def\openH{{{\mathrm I}\kern-.16em {\mathrm H}}}
\def\openK{{{\mathrm I}\kern-.16em {\mathrm K}}}
\def\openN{{{\mathrm I}\kern-.16em {\mathrm N}}}
\def\openP{{{\mathrm I}\kern-.16em {\mathrm P}}}
\def\openQ{{\mathrm Q\kern-.21cm\vrule width.6pt height 6.2ptdepth-.2pt \kern.21cm}}
\def\openQ{{{\mathrm Q}\kern-.63em {\mathrm Q}}}
\def\openR{{{\mathrm I}\kern-.16em {\mathrm R}}}
\def\openS{{{\mathrm S}\kern-.68em{\mathrm S}}}
\def\openT{{{\mathrm T}\kern-.30em {\mathrm T}}}
\def\openZ{{{\mathrm Z}\kern-.28em{\mathrm Z}}}

\def\sumZ{\sum_{j\in\Zd}}
\def\Iff{\hskip1em\Longleftrightarrow\hskip1em}
\def\iff{\Longleftrightarrow}
\def\Implies{\hskip1em\Longrightarrow\hskip1em}
\def\implies{\Longrightarrow}
\def\Implied{\hskip1em\Longleftarrow\hskip1em}
\def\implied{\Longleftarrow}

\def\ga{\alpha}
\def\gA{{\mathrm A}}
\def\gb{\beta}
\def\gB{{\mathrm B}}
\def\gga{\gamma}
\def\gG{\Gamma}
\def\gd{\delta}
\def\gD{\Delta}
\def\gep{\epsilon}
\def\gz{\zeta}
\def\gZ{{\mathrm Z}}
\def\gth{\theta}
\def\gTh{\Theta}
\def\gk{\kappa}
\def\gl{\lambda}
\def\gL{\Lambda}
\def\gm{\mu}
\def\gM{\mathrm M}
\def\gn{\nu}
\def\gf{\varphi}
\def\gF{\Phi}
\def\gy{\upsilon}
\def\gk{\kappa}
\def\gs{\sigma}
\def\gS{\Sigma}
\def\gt{\tau}
\def\gT{{\mathrm T}}
\def\gr{\varrho}
\def\gR{{\mathrm P}}
\def\Chi{{\mathrm X}}
\def\go{\omega}
\def\gO{\Omega}

%
% Shortcut for commands
%


\newcommand{\SingleSpace}{\edef\baselinestretch{0.9}\Large\normalsize}
\newcommand{\DoubleSpace}{\edef\baselinestretch{1.4}\Large\normalsize}
\newcommand{\Heading}[1]{\par\noindent{\bf#1}\nopagebreak\ }
\newcommand{\Tail}[1]{\nopagebreak\par\noindent{\bf#1}}
\newcommand{\QED}{\vrule height 1.4ex width 1.0ex depth -.1ex\ } % square box
\@ifundefined{flalign}
{
}
{
\renewcommand{\atop}[2]
  {\genfrac{}{}{0pt}{}{#1}{#2} }
}


%
% convex analysis definitions
%

\@ifundefined{flalign}
{
  \newcommand{\Aff}{\insmat{aff}}
  \newcommand{\Conv}{\insmat{conv}}
  \newcommand{\Diag}{\insmat{diag}}
  \newcommand{\Eff}{\insmat{eff}}
  \newcommand{\Paral}{\insmat{par}}
  \newcommand{\Intr}{\insmat{int}}
  \newcommand{\Ri}{\insmat{ri}}
  \newcommand{\Cl}{\insmat{cl}}
  \newcommand{\Co}{\insmat{co}}
  \newcommand{\Bdry}{\insmat{bdry} }
  \newcommand{\Cone}{\insmat{cone} }
  \newcommand{\Rec}{\insmat{rec} }
  \newcommand{\Lin}{\insmat{lin} }
  \newcommand{\EEP}{\insmat{EP} }
}
{
  \RequirePackage{amsgen}
  \DeclareMathOperator*{\Aff}{aff}
  \DeclareMathOperator*{\Conv}{conv}
  \DeclareMathOperator*{\Diag}{diag}
  \DeclareMathOperator*{\Eff}{eff}
  \DeclareMathOperator*{\Paral}{par}
  \DeclareMathOperator*{\Intr}{int}
  \DeclareMathOperator*{\Ri}{ri}
  \DeclareMathOperator*{\Cl}{cl}
  \DeclareMathOperator*{\Co}{co}
  \DeclareMathOperator*{\Bdry}{bdry}
  \DeclareMathOperator*{\Cone}{cone}
  \DeclareMathOperator*{\Rec}{rec}
  \DeclareMathOperator*{\Lin}{lin}
  \DeclareMathOperator*{\EEP}{EP}
}

\newcommand{\aff}[1]{\Aff #1}
\@ifundefined{diag}
{
\newcommand{\diag}[1]{\Diag\left (#1 \right )}
}{}
\newcommand{\eff}[1]{\Eff #1}
\newcommand{\conv}[1]{\Conv #1}
\newcommand{\paral}[1]{\Paral #1}
\newcommand{\intr}[1]{\Intr #1}
\newcommand{\ri}[1]{\Ri #1}
\newcommand{\cl}[1]{\Cl #1}
\newcommand{\co}[1]{\Co\left( #1 \right)}
\newcommand{\clco}[1]{\cl{\co{#1}}}
\newcommand{\bdry}[1]{\Bdry #1}
\newcommand{\cone}[1]{\Cone #1}
\newcommand{\rec}[1]{\Rec #1}
\newcommand{\lin}[1]{\Lin #1}
\newcommand{\EP}[1]{\EEP\left (#1 \right )}

\newcommand{\barrier}[1]{\insmat{bar} #1}
\newcommand{\conj}[1]{#1^*}
\newcommand{\indicator}[2]{\psi(#1 \mid #2)}
\newcommand{\indfn}[1]{\indicator{\cdot}{#1}}
\newcommand{\support}[2]{\conj{\psi}(#1 \mid #2)}
\newcommand{\suppfn}[1]{\support{\cdot{#1}}}
\newcommand{\dist}[2]{\insmat{dist}(#1 \mid #2)}
\newcommand{\distfn}[1]{\dist{\cdot}{#1}}
\newcommand{\ncone}[2]{N(#1 \mid #2)}
\newcommand{\tcone}[2]{T(#1 \mid #2)}
\newcommand{\pcone}[1]{{#1}^\circ}
\newcommand{\polar}[1]{{#1}^\circ}
\newcommand{\epi}[1]{\insmat{epi} #1}
\newcommand{\epiwrt}[2]{\inmat{epi}_{#2}#1 }


%
% numerical analysis definition
%
\@ifundefined{flalign}
{
   \def\Rank{\mathop{\mathrm rank}}
   \def\SSpan{\mathop{\mathrm span}}
   \def\NNull{\mathop{\mathrm null}}
}
{
  \RequirePackage{amsgen}
  \DeclareMathOperator*{\Rank}{rank}
  \DeclareMathOperator*{\SSpan}{span}
  \DeclareMathOperator*{\NNull}{null}
}
\@ifundefined{rank}
{
\newcommand{\rank}[1]{\Rank #1}
}{}
\newcommand{\Span}[1]{\SSpan #1}
\newcommand{\spam}[1]{\SSpan #1}
\newcommand{\Null}[1]{\NNull #1}


%
% shorter definitions for common usages
%

\newcommand{\ba}{\begin{array}}
\newcommand{\ea}{\end{array}}
\newcommand{\bc}{\begin{center}}
\newcommand{\ec}{\end{center}} \newcommand{\ds}{\displaystyle}
\newcommand{\arrayc}[1]{\ba{c} #1 \ea}
\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}

%
% problem definitions and mathematical constructions
%

\newcommand{\argmin}{\insmat{argmin}}

\DeclareOption{italian}
   {
     \newcommand{\subjectto}{\insmat{soggetto a}}
     \newcommand{\maximize}{\insmat{max}}
     \newcommand{\minimize}{\insmat{min}}
   }
\DeclareOption{english}
   {
     \newcommand{\subjectto}{\insmat{subject to}}
     \newcommand{\maximize} {\insmat{max}}
     \newcommand{\minimize} {\insmat{min}}
   }
\ProcessOptions

\newcommand{\eeqncond}[3]
        {\begin{equation} \ba{rl} #1 & \mbox{   #2} \ea \label{#3}
         \end{equation}}
\newcommand{\eqncond}[2]
        {\[ \ba{rl} #1 & \mbox{   #2} \ea \] }
\newcommand{\simpleproblem}[3]
    {\ba{lc} {\ds #3_{#2}} & {#1} \ea}
\newcommand{\epmin}[3]
    {\begin{equation} \simpleproblem{#1}{#2}{\minimize} \label{#3}
         \end{equation}}
\newcommand{\pmin}[2]
    {\[ \simpleproblem{#1}{#2}{\minimize} \] }
\newcommand{\epmax}[3]
    {\begin{equation} \simpleproblem{#1}{#2}{\maximize} \label{#3}
         \end{equation}}
\newcommand{\pmax}[2]
    {\[ \simpleproblem{#1}{#2}{\maximize} \] }
\newcommand{\problem}[4]
    {\ba{lc} {\ds #4_{#1}} & {#2} \\*
        {\subjectto} & {\ba[t]{c} #3 \ea}
     \ea}
\newcommand{\eprobmin}[4]
    {\begin{equation} \problem{#1}{#2}{#3}{\minimize} \label{#4}
         \end{equation}}
\newcommand{\probmin}[3]
    {\[ \problem{#1}{#2}{#3}{\minimize} \] }
\newcommand{\eprobmax}[4]
    {\begin{equation} \problem{#1}{#2}{#3}{\maximize} \label{#4}
         \end{equation}}
\newcommand{\probmax}[3]
    {\[ \problem{#1}{#2}{#3}{\maximize} \] }
\newcommand{\compproblem}[2]
    { \ba{rcl} #2 \ge 0 \\* #1 \ge 0 \\* \ip{#1}{#2} = 0 \ea }
\newcommand{\compproblemb}[2]
    { \ba{rcl} #2 \ge 0 \\* #1 \ge 0 \\* \ip{#1}{(#2)} = 0 \ea }
\newcommand{\ecomp}[3]
    {\begin{equation}
        \compproblem{#1}{#2} \label{#3}
         \end{equation}}
\newcommand{\ecompb}[3]
    {\begin{equation}
        \compproblemb{#1}{#2} \label{#3}
         \end{equation}}
\newcommand{\comp}[2]
    {\[ \compproblem{#1}{#2} \] }
\newcommand{\compb}[2]
    {\[ \compproblemb{#1}{#2} \] }

%
% theorem and the like
%
\@ifundefined {flalign}
{
  \def\emptybox
  {
    {\ \vbox{\hrule \hbox%
               {%
                 \vrule height 1.3ex%
                 \hskip 0.8ex\vrule%
               }\hrule%
            }
    }
  }
  \def\qed{\emptybox}
  \def\endproof{\par \hfill \qed \par}
} { }

\DeclareOption{italian}
   {
      \newtheorem{thm}{Teorema}[section]
      \newtheorem{cor}[thm]{Corollario}
      \newtheorem{lem}[thm]{Lemma}
      \newtheorem{prop}[thm]{Proposizione}
      \newtheorem{fact}{Fatto}[section]
      \@ifundefined {flalign} { }
      {
        \theoremstyle{definition}
      }
      \newtheorem{defn}{Definizione}[section]
      \@ifundefined {flalign} { }
      {
        \theoremstyle{remark}
      }
      \newtheorem{remark}{Nota}[section]
      \@ifundefined {flalign} { }
      {
        \theoremstyle{remark}
      }
      \newtheorem{Note}[remark]{Nota}
      \newtheorem{conjecture}{Congettura}[section]
      \newtheorem{exa}{Esempio}[section]
      \@ifundefined {flalign}
      {
          \def\proof{\par\noindent{%
               {\bf Dimostrazione.}%
                  \ignorespaces}}{ }
      }
      {
           \renewcommand{\proofname}{Dimostrazione}
      }
   }
\DeclareOption{english}
   {
      \newtheorem{thm}{Theorem}[section]
      \newtheorem{cor}[thm]{Corollary}
      \newtheorem{lem}[thm]{Lemma}
      \newtheorem{prop}[thm]{Proposition}
      \newtheorem{fact}{Fact}[section]
      \@ifundefined {flalign} { }
      {
        \theoremstyle{definition}
      }
      \newtheorem{defn}{Definition}[section]
      \@ifundefined {flalign} { }
      {
        \theoremstyle{remark}
      }
      \newtheorem{remark}{Remark}[section]
      \newtheorem{Note}[remark]{Remark}
      \newtheorem{conjecture}{Conjecture}[section]
      \newtheorem{exa}{Example}[section]
      \@ifundefined {flalign}
      {
          \def\proof{\par\noindent{%
               {\bf Proof.}%
                  \ignorespaces}}{ }
      }{ }
   }
\ProcessOptions

%\def\proof{\par\noindent{%
%         \ifx\dateitalian\undefined%
%            {\bf Proof}%
%         \else%
%             {\bf Dimostrazione}%
%          . \ignorespaces}}
%\def\endproof {\par \hfill \emptybox \par}

 

%\def\blackbox{\vrule height 1.3ex width 0.8ex }
%\def\emptybox
%{
%  {\ \vbox{\hrule \hbox%
%             {%
%               \vrule height 1.3ex%
%               \hskip 0.8ex\vrule%
%             }\hrule%
%          }
%  }
%}

 


%
%  definition command
%
\makeatletter
\@ifundefined {flalign}
{
\newcommand\ifdefin[5]
{\[ #1 \define \left \{
     \begin{array}{ll}
      #2  & #3  \\ \\
          #4  & #5
     \end{array}
\right . \]
}
}{ }
\makeatother

now can you tell me how can i introduce this function, so that jsMath can compile it like another mathematic command?

thank you Davide

In reply to Francesco Passarini

Re: LaTeX file used verbatimi within Moodle?

by Davide Cervone -
Thanks for posting the code, but because some of the macros included the math-mode delimiters (double-dollars) it was typeset by the tex filter, but I think I can figure out what was there.

Most of your file could be converted to be used with jsMath, but there are a few things that could not. For example, jsMath won't handle the \label commands, and it doesn't stretch \vrule and \hrule to match the size of the containing box. But most of what you have could be converted.

There are a lot of shorthand symbols defined, and if these get used within the problems, you'll want to tell jsMath about them.

Unfortunately, when I was testing out your example, I found a bug in jsMath that I will have to fix before it will work on your code. But I am not going to be able to do that for several weeks, I'm afraid, so I won't have a solution for you until mid August. If you can wait until then, I'll see what I can do.

Davide

In reply to Davide Cervone

Re: LaTeX file used verbatimi within Moodle?

by Francesco Passarini -

thanks Davide.

what do you think is better for my project, try to use another Filter which can work in Windows and which can compile this kind of file or not?

maybe i can also try to find a solution with this file using only the command that jsMath can compile and then looking if the result is the same one which i had when all the component work usind the latex editor.

but i think it's too hard for me. i'll have a big work to do.

if i'll able to do something (waiting your help too) where i have to save then the file? in which folder of the filter?

 

see us soon and thank you again Davide.

In reply to Francesco Passarini

Re: LaTeX file used verbatimi within Moodle?

by Davide Cervone -
what do you think is better for my project, try to use another Filter which can work in Windows and which can compile this kind of file or not?

I don't think you will find a filter that does that, and if you want to process your files with the least amount of modification, I think jsMath is going to be your best bet. It at least lets you define macros, and it will work once I fix the errors that I found. (There are two, one easy and one hard.)


maybe i can also try to find a solution with this file using only the command that jsMath can compile and then looking if the result is the same one which i had when all the component work usind the latex editor.

You certainly could use jsMath directly for these problems, by not using \probmax and laying out the problem by hand. One of the errors I found was in the array layout part of jsMath (the hard one to fix), but you could use HTML tables for that instead.

For example, you could enter this particular problem using the HTML format as:

<TABLE CELLPADDING="10">
<TR><TD>\(\max\limits_{x_1,x_2}\)</TD><TD>\(2x_1 + x_2\)</TD></TR>
<TR VALIGN="top"><TD>subject to</TD><TD>
\(x_2 \leq 10\)<BR>
\(2x_1 + 5x_2 \leq 60\)<BR>
\(x_1 + x_2 \leq  18\)<BR>
\(3x_1 + x_2 \leq 44\)<BR>
\(x_1 \geq 0, x_2 \geq 0\)
</TD></TR>
</TABLE>
Not ideal, but it works. The "subject to" conditions could be entered as an array if you want, but it is hard to edit problems that contain \\, since Moodle tends to replace them by single \ for editing (something that really needs to be fixed).


where i have to save then the file? in which folder of the filter? I'm not sure which file you have in mind, but if you mean the problem itself, then you don't store the file by hand, you use Moodle's web interface to create the problems.

I assume you are going to be using the Quiz module for this? If so, you should add a quiz to your course, and when you click on the quiz, you should have an "Edit Quiz" tab, which you can use to add problems to the quiz. From that page, there is a pane at the lower right that lists the available problems (none at the moment, I would assume). The menu above that lets you create new quiz problems, and you can select the type from that menu. For example, "Numerical" would work for the example above. Selecting this in the menu should bring up a window that lets you enter the text of the problem and provide the correct answer.

I have never really used the Quiz module, but it looks pretty straight forward to me. If you need additional help with quizzes, you should first look at the documentation for the Quiz module, and then search this forum for similar questions about the Quiz module. I'm afraid I won't be able to be of much other help there.

Davide

In reply to Davide Cervone

Re: LaTeX file used verbatimi within Moodle?

by Alison Schubert -
One of the errors I found was in the array layout part of jsMath (the hard one to fix)

Does this explain why columns which are suppose to be right aligned end up centered?  I've been entering arrays and equation arrays and just noticed this behaviour yesterday.  It seemed odd, but I figured it was easier to leave it then change all the entries to html tables.
In reply to Alison Schubert

Re: LaTeX file used verbatimi within Moodle?

by Davide Cervone -
No, I'm not aware of a problem with right alignment (but I haven't looked for one recently). Can you given the code for an example that doesn't work (being careful to make sure it displays properly as TeX source code)?

Davide
In reply to Davide Cervone

Re: LaTeX file used verbatimi within Moodle?

by Alison Schubert -
It properly aligns the first row, which stretches all the way across but fails on the latter rows.  This may not be a bug so much as a difference in LaTex implementations, but here's an example (that seems to look worse alignment wise here then on my server).

\$\$\begin{array}{rcl}1&<&4-3x&<&16\\ 1-4&<&-3x&<&16-4\\ -3&<&-3x&<&12\\ \frac{-3}{-3}&>&x&>&\frac{12}{-3}\\ 1&>&x&>&-4 \end{array}\$\$

displays as:
$$\begin{array}{rcl}1&<&4-3x&<&16\\\ 1-4&<&-3x&<&16-4\\\ -3&<&-3x&<&12\\\ \frac{-3}{-3}&>&x&>&\frac{12}{-3}\\\ 1&>&x&>&-4 \end{array}$$

Third time editing is the charm wink
In reply to Alison Schubert

Re: LaTeX file used verbatimi within Moodle?

by Davide Cervone -
You have only given 3 column specifiers, but have used 5 columns. The last two go to "c" by default. Perhaps you mean \begin{array}{rcccl} ?

Davide
In reply to Davide Cervone

Re: LaTeX file used verbatimi within Moodle?

by Alison Schubert -
doh!  Your right, to long typing eqnarray's.  Sorry about that.
In reply to Davide Cervone

Re: LaTeX file used verbatimi within Moodle?

by Francesco Passarini -

hi davide and hi at all,

i have a problem now.

i'm upgrading my version of Moodle from 1.5.4 to 1.6.

the process is not complete because i'm a problem to update my database version, but i can move me into my upgrade site.

i instelled jsMath but i make it available, but when i write a mathematic line with the $$ it doesn't compile anything.

why? can you help me?

thank you again

 

In reply to Francesco Passarini

Re: LaTeX file used verbatimi within Moodle?

by Davide Cervone -
Do you see the TeX code, or does the mathematics disappear entirely? Do you see the jsMath button at the lower right? If you look at the JavaScript Console for your browser, do you get any error messages? Finally, did you clear your browser cache after enabling jsMath (the jsMath filter includes new code in the javascript-mod.php output, but your browser may be using a cached version from before jsMath was installed).

See if one of those helps.

Davide
In reply to Davide Cervone

Re: LaTeX file used verbatimi within Moodle?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Moodle 1.6 permits the use of arbitrary LaTeX documents - not just maths stuff although it relies on LaTeX and ghostscript binaries being present. The preamble lives in the admin=>filter=>tex settings page. All the rest goes on the page with the usual $$ at the start and end.