Re: [mnemosyne-proj-users] LaTeX and Cloze/sentences

139 views
Skip to first unread message

Peter Bienstman

unread,
Mar 3, 2013, 2:34:41 AM3/3/13
to mnemosyne-...@googlegroups.com
Good catch! I'll make sure it's fixed for the next release.

Thanks,

Peter

Quoting acd...@gmail.com:

> You can see an example of what I want to do by making this Cloze card:
>
> [Lorentz force law]
> <$>[\mathbf{F}]=[q]([\mathbf{E}]+[\mathbf{v}\times\mathbf{B}]</$>
>
> My problem is that the answer side of the card is not in LaTeX.
>
> This for example only works for the last card:
>
> [Lorentz force law]
> <$>[\mathbf{F}]=[q]([\mathbf{E}]+[<$>\mathbf{v}\times\mathbf{B}</$>])</$>
>
> And this messes up the rendering:
>
> [Lorentz force law]
> [<$>\mathbf{F}</$>]<$>=</$>[<$>q</$>]<$>(</$>[<$>\mathbf{E}</$>]<$>+</$>[<$>\mathbf{v}\times\mathbf{B}</$>]<$>)</$>
>
> With more complex expressions that simply would not work.
>
> Could you please make the program detect when [...] is inside LaTeX
> tags and copy them to the answer card?
>
> --
> You received this message because you are subscribed to the Google
> Groups "mnemosyne-proj-users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to mnemosyne-proj-u...@googlegroups.com.
> To post to this group, send email to mnemosyne-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mnemosyne-proj-users/-/RGWOMmJJVTUJ.
> For more options, visit https://groups.google.com/groups/opt_out.



Peter Bienstman

unread,
Apr 2, 2013, 2:45:35 AM4/2/13
to mnemosyne-...@googlegroups.com
This is fixed in the 2.2.1-RC1 I recently posted to this forum.

Cheers,

Peter

On 04/01/2013 07:10 PM, richar...@googlemail.com wrote:
> Also, I may have found a small bug with the way that cloze within latex is handled. Consider the following card:
>
> <latex>
> $$ G(s)=[\frac{A}{B}C] $$
> </latex>
> <$$>G(s)=[\frac{A}{B}C]</$$>
>
> I would expect these to render the same, but for me only the second renders as I want it to - in the 'full' latex environment, the fraction renders instead as if I had written [A\frac{}{BC}].
>
> Does anyone else observe the same? I am new to latex so may be misunderstanding some aspect. Thanks.
>

Peter Bienstman

unread,
Apr 2, 2013, 2:48:10 AM4/2/13
to mnemosyne-...@googlegroups.com
On 04/01/2013 02:31 PM, richar...@googlemail.com wrote:
> Thanks for this fix, it was very useful for me too. On a somewhat related note, how can I make square brackes [ ] appear in my (latex) cloze cards instead of being interpreted as cloze delimiters?

I'm afraid that at the moment you either have to change them to e.g. {}.
or use a non-Cloze card type.

Peter

Peter Bienstman

unread,
Apr 2, 2013, 4:00:02 AM4/2/13
to mnemosyne-...@googlegroups.com
Hi,

The issue is that if you write:

<latex>
$$ G(s)=[\frac{A}{B}C] $$
</latex>

The question will become

<latex> \frac{A}{B}C </latex>

i.e. Mnemosyne will not pick up any open environments which contain the
cloze, like in this case $$

I've had a similar bug reports for open tags in table html. Both of
these issues are solvable in theory, but would require a lot a of
effort, in essence building a html or latex parser for the cloze card
type. I'm afraid this would be overkill, especially as there are
alternatives to get the behaviour you want...

Peter

On 04/02/2013 08:51 AM, richar...@googlemail.com wrote:
> On Tuesday, 2 April 2013 07:45:35 UTC+1, Peter Bienstman wrote:
>> This is fixed in the 2.2.1-RC1 I recently posted to this forum.
>
> Sorry I should have mentioned - I am using that new release. I downloaded from the link on this forum and used the instructions on the main website to run it from my USB stick.
>

Peter Bienstman

unread,
Apr 3, 2013, 8:39:18 AM4/3/13
to mnemosyne-...@googlegroups.com
In very rare cases you could get a hash collision which could cause this.

Or is this something that you can reproduce?

Peter

On 04/03/2013 02:37 PM, richar...@googlemail.com wrote:
> Also, sometimes cached latex pngs from other cards get reused instead of the correct content being generated up. The following shows me editing a card and then pressing preview:
>
> http://i.imgur.com/h4IoOQ5.png
>

Richard Kemp

unread,
Apr 3, 2013, 8:42:54 AM4/3/13
to mnemosyne-...@googlegroups.com
I haven't yet noticed a particular set of steps to reliably generate the behaviour, but it is certainly more common than a hash collision. It has happened several times today.

I don't know if this will make a difference to you but I have been trying out new fonts, plus I have been attempting to work around the 'false latex' issue by deleting the latex media folder and restarting mnemosyne - it keeps recurring.


--
You received this message because you are subscribed to a topic in the Google Groups "mnemosyne-proj-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mnemosyne-proj-users/3g-G3laB4zo/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to mnemosyne-proj-users+unsub...@googlegroups.com.
To post to this group, send email to mnemosyne-proj-users@googlegroups.com.

Peter Bienstman

unread,
Apr 3, 2013, 8:47:07 AM4/3/13
to mnemosyne-...@googlegroups.com
I haven't seen anything like this myself, but let me know if you can
find a pattern.

Peter

Peter Bienstman

unread,
Apr 3, 2013, 9:12:24 AM4/3/13
to mnemosyne-...@googlegroups.com
I haven't forgotten about this, I'll debug it when I get home from work :-)

On 04/03/2013 03:09 PM, richar...@googlemail.com wrote:
> Any thoughts about my post of 13:22?
Message has been deleted

Peter Bienstman

unread,
Apr 3, 2013, 2:08:44 PM4/3/13
to mnemosyne-...@googlegroups.com
What I recommend doing in this case is looking at the _latex subdir in
the media dir, and checking out tmp.tex to see what gets fed into the
latex parser, as well as the error files to see if latex encountered
an error.

Peter

Quoting richar...@googlemail.com:

> http://i.imgur.com/xGsYrTg.png
>
> More weirdness, note the !latex? in the top right.
>
> --
> You received this message because you are subscribed to the Google
> Groups "mnemosyne-proj-users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to mnemosyne-proj-u...@googlegroups.com.
> To post to this group, send email to mnemosyne-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mnemosyne-proj-users/-/yujlIZV_OKUJ.

Peter Bienstman

unread,
Apr 3, 2013, 2:09:10 PM4/3/13
to mnemosyne-...@googlegroups.com
Fixed, thanks!

Peter

Quoting richar...@googlemail.com:

> Something else:
>
> <latex>
> [$a^2+b^2=c^2$:abc]
> </latex>
>
> If a cloze hint is used like this, the answer is not rendered by
> latex. Without the hint, it is.


Peter Bienstman

unread,
Apr 4, 2013, 12:10:12 AM4/4/13
to mnemosyne-...@googlegroups.com
Have you set custom preambles, postambles, ... ?

Peter


richar...@googlemail.com wrote:
An example of weirdness: I deleted the _latex folder and opened Mnemosyne. The first card displayed fine, then the second card I viewed displayed as follows (source on the right):

http://i.imgur.com/UQdufzC.png

contents of tmp.tex:

\documentclass[9pt]{article}
\pagestyle{empty}
\newcommand{\mathtiny}[1]{\mbox{\tiny $#1$}}
\newcommand{\ssub}[1]{_{\mbox{\tiny $#1$}}}
\usepackage{amsmath}
\hfill\small \normalsize\\
\setlength{\textwidth}{375}
\setlength{\parindent}{0pt}



\begin{document}
\frac{d^2}{dt^2}y(t)+2\zeta\omega_n\frac{d}{dt}y(t)+\omega_n^2y(t)=\omega_n^2u(t)
\end{document}



You notice not only is that TeX a bit messed up (\hfill\small \normalsize\\ should not be before \begin{document}) but also this TeX is not actually from this card! Mnemosyne seems to have re-used the answer to the previous card as the question for this card. Hope this narrows it down a bit for you.

Peter Bienstman

unread,
Apr 4, 2013, 9:26:55 AM4/4/13
to mnemosyne-...@googlegroups.com
OK, but to help me reproduce this, could you send me a sequence of steps like

-deleted _latex dir
-set preamble to such and auch
-created a card with contents foo, pressed preview
-created a card with contents bar, pressed preview, got picture from foo

Basically all the details and information needed to reproduce this.

Thanks!

Peter

Citeren richar...@googlemail.com:

> So I should pay more attention, you're right that my preamble was
> messed up. This however was not causing mnemosyne to send incorrect
> content to latex..
>
> --
> You received this message because you are subscribed to the Google
> Groups "mnemosyne-proj-users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to mnemosyne-proj-u...@googlegroups.com.
> To post to this group, send email to mnemosyne-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mnemosyne-proj-users/-/PxmbKrV25poJ.

Arno den Hartog

unread,
Apr 5, 2013, 12:04:53 AM4/5/13
to mnemosyne-...@googlegroups.com
Regarding [ and [ brackets, maybe you could add an exception for \left[ and \right]
I know LyX outputs brackets that way.

Peter Bienstman

unread,
Apr 5, 2013, 2:40:29 AM4/5/13
to mnemosyne-...@googlegroups.com
That's actually not a bad suggestion, as it does not introduce any
ad-hoc new escaping syntax. I'll have a shot at implementing this.

Thanks!

Peter
> --
> You received this message because you are subscribed to the Google
> Groups "mnemosyne-proj-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mnemosyne-proj-u...@googlegroups.com.
> To post to this group, send email to mnemosyne-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mnemosyne-proj-users/-/BXGALNjpSYEJ.

Peter Bienstman

unread,
Apr 5, 2013, 2:46:26 AM4/5/13
to mnemosyne-...@googlegroups.com
BTW, I think I know what's happening here: the second latex card
probably has some errors in it, which causes the latex compiler to fail.
However, there is still a dvi file from the previous latex card there,
which gets used as input for dvipng.

I'll simply remove the dvi file before each latex pass, that should
alert you to the fact that something is wrong with your latex code.

Cheers,

Peter
--
Peter Bienstman
Ghent University, Dept. of Information Technology
Sint-Pietersnieuwstraat 41, B-9000 Gent, Belgium
tel: +32 9 264 34 46, fax: +32 9 264 35 93
WWW: http://photonics.intec.UGent.be
email: Peter.B...@UGent.be

Peter Bienstman

unread,
Apr 5, 2013, 8:04:21 AM4/5/13
to mnemosyne-...@googlegroups.com
To figure out what is going wrong in your latex code, have a look at the
error log in the _latex dir.

Peter

On 04/05/2013 12:43 PM, richar...@googlemail.com wrote:
> That should help in figuring out at which stage things are going wrong, thanks. Thus far I've been unable to figure out what causes it. It could well be a latex error as I'm not experienced with it.
>
> Will you upload a new RC any time soon, or should I compile my own?

Peter Bienstman

unread,
Apr 10, 2013, 11:52:43 PM4/10/13
to mnemosyne-...@googlegroups.com
Are you sure you are using RC3? Option 1 should work there.

Peter


sni...@gmail.com wrote:
Hi Peter, I have a small request related to those above. As mentioned it is probably impractical for you to parse LaTeX to pass all environments and formats through from outside to inside a cloze bracket. Perhaps one exception could be made? I am having trouble writing math formulae using the $$ notation and cloze. If I write I have tried:
$$[ .. ]$$ this is right when the cloze is ignored, but math tags are not passed when this close is used,
[$$ .. $$] when this close is used, the answer is rendered correctly but the question lacks the new line before and after so the layout is wrong,
$$[$ .. $]$$ renders right when this cloze is used, but the tags cancel each other when another cloze is used.
So, none give the behaviour I want. Could you add a small new escape sequence such that using $$[ .. ]$$ includes the math tags on 'both sides' when the cloze contents are rendered as an answer?

I hope you see what I mean and this is not an unreasonable request. Thanks for all your work on this excellent tool.
Reply all
Reply to author
Forward
0 new messages