8
$\begingroup$

When giving hints to a problem, sometimes it's beneficial to use the spoiler markers >!, however if the reasoning is longer and split into more than one hint, then this leads to bad user experience. For example, consider a post with two hints:

Hint 1:

Define $x = \text{(some complex formula)}$.

Hint 2:

Observe that $f(x) = 0$.

Then, if the user wishes to read the second hint, the first disappears (along with the complex formula inside). I know that one can select the post (i.e. highlight) so that the text becomes visible, but that's only a temporary solution.

In short, it would be great if we could have spoiler markers that would support hierarchical behavior. For example, we could write:

>! hint 1
>! >! hint 2

That could be solved also by toggle-button functionality (which also makes sense for mobile devices), but some say it's not such a good idea.

I suspect that's not easy to add, but might be worth considering if some other changes were to be made as well (e.g. fixing spoilers and MathJax interaction).

What do you think?

Edit:

A feature easier to implement: a serial behavior, which could be triggered by something like
<!-- spoilers: serial --> in fashion similar to stack-overflow's syntax highlighting
<!-- language: lang-or-tag-here --> feature.

$\endgroup$
  • 1
    $\begingroup$ @user147263 I disagree, each SE community is different and I think that math.se could benefit from such feature. In particular, we allow homework questions, for which hints and spoiler markers are of great use (this is also the main use case, notably 10% of questions are tagged homework). $\endgroup$ – dtldarek May 16 '14 at 16:34
  • 2
    $\begingroup$ Yes, hierarchical hint capability is one of the major pedagogical advantages of ebooks vs. static paper books. We really should exploit such capabilities more frequently here. Currently most answers here do not exploit the extra capabilities vs. paper books. $\endgroup$ – Bill Dubuque May 16 '14 at 18:39
  • $\begingroup$ They both show up when i am using my phone... $\endgroup$ – user1729 May 16 '14 at 19:17
  • 3
    $\begingroup$ If I click on hint 1 (instead of just hovering the mouse) it seems to stay around. Click again and then it disappears. $\endgroup$ – TravisJ Jun 6 '15 at 22:47
  • $\begingroup$ Note that after clicking again to hide, the spoiler will disappear only after the pointer is moved outside the spoiler bounding box. It is possible that some of this functionality was implemented after the above question was asked. $\endgroup$ – Bill Dubuque Jun 28 '15 at 15:17
  • $\begingroup$ @BillDubuque You are right, and I don't remember this behavior at the time of asking. Not exactly what I wanted, but the solution is good enough and simple, which is very important. $\endgroup$ – dtldarek Jun 28 '15 at 20:13
  • $\begingroup$ This must be out of date — I touch the first and it shows; I touch the second and it shows too. The first does not disappear. Isn't this something we want “fixed” on the html/css level of page rendering? $\endgroup$ – JDługosz May 28 '17 at 3:29
21
$\begingroup$

The toggle button functionality is more or less available through the MathJAX extension action. Though it is more suitable for displaying alternate math formulas instead of displaying a paragraph of text. Personally, I can't think of any good way to utilize this functionality.

$$\require{action} \toggle{ \begin{array}{cl} & \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{ \verb/click me for hint/} \end{array} }{ \begin{array}{cl} 1. & \text{Define }x \text{ = (complex formula)}\\ & \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{ \verb/more hint.../} \end{array} }{ \begin{array}{cl} 1. & \text{Define }x\text{ = (complex formula)}\\ 2. & \text{Observe } f(x) = 0\\ & \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{ \verb/That's it, thanks for wasting your time!/} \end{array} } \endtoggle$$

Code implementing above behavior follows

$$\require{action}
\toggle{
\begin{array}{cl}
& \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{
\verb/click me for hint/}
\end{array}
}{
\begin{array}{cl}
1. & \text{Define }x \text{ = (complex formula)}\\
& \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{
\verb/more hint.../}
\end{array}
}{
\begin{array}{cl}
1. & \text{Define }x\text{ = (complex formula)}\\
2. & \text{Observe } f(x) = 0\\
& \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{
\verb/That's it, thanks for wasting your time!/}
\end{array}
}
\endtoggle$$
$\endgroup$
  • 7
    $\begingroup$ +1 wow... ${ }$ $\endgroup$ – draks ... May 16 '14 at 19:07
  • 1
    $\begingroup$ I can think of a "proper" use of a toggle. To toggle colorations (or other forms of emphasis) of paths through a diagram indicating in turn a first path/second path/etc. For instance, have you ever traced a commutative diagram with your finger while reading a proof. $\endgroup$ – Karl Kronenfeld May 17 '14 at 1:49
  • 1
    $\begingroup$ Also, you can implement toggles that don't allow you to return to the original "click me" message after spoiling: $$\require{action}\toggle{\text{Click me}}{\toggle{1+1=2}{1+1=2}\endtoggle}\endtoggle$$ $\endgroup$ – Karl Kronenfeld May 17 '14 at 1:55
  • $\begingroup$ This is great, not exactly what I would wish for, but at least partially solves the problem. $\endgroup$ – dtldarek May 21 '14 at 12:03
  • $\begingroup$ $$\newcommand{\myspoiler}[2][padding: 4px;]{ \style{background-color: rgb(240,240,240);#1}{\class{spoiler}{#2}}} \text{ A test of alternate implementation of } \myspoiler[padding: 8px;]{\text{spoiler!}}$$ $\endgroup$ – achille hui Mar 7 '15 at 15:31
  • 1
    $\begingroup$ Guys. Assembly code is more transparent than this!!! $\endgroup$ – steven gregory Jun 28 '15 at 14:43
  • 1
    $\begingroup$ @Steven: Not if you use the AT&T convention! :-) $\endgroup$ – Asaf Karagila Jun 28 '15 at 16:43
  • $\begingroup$ For ordinary posts, I can click "edit" to see the source code. Is there something similar to this for comments (I would like to see the code used in the comments above). $\endgroup$ – PhoemueX Jul 26 '15 at 7:00
  • $\begingroup$ @PhoemueX right click on the piece marked up by MathJAX and then choose "Show Math As --> TeX Commands". $\endgroup$ – achille hui Jul 26 '15 at 13:21
  • $\begingroup$ @PhoemueX Or for the entire comment markdown, see meta.stackexchange.com/questions/286234 if you don't want to use the API directly $\endgroup$ – punctured dusk May 28 '18 at 14:29
10
$\begingroup$

Clicking a hint makes it stay visible even when the mouse stops hovering it (clicking it again makes it fade again). Thus one can click the first hint, and only then click the second. Hierarchical hints (or a horrifying mathjax hack) are not necessary.

$\endgroup$
  • 5
    $\begingroup$ Horrifying, but incredibly awesome. $\endgroup$ – Asaf Karagila Jun 28 '15 at 16:43
  • $\begingroup$ I don't remember that feature to be available at the time, but I'm glad it is working now (esp. it's much better for mobile devices). $\endgroup$ – dtldarek Jun 28 '15 at 20:15
  • $\begingroup$ You might consider accepting this answer; the MathJax hack was an interesting piece of technical wizardry but (given that this feature seems to exist now) it will be much simpler to write ordinary spoilers and let people click on them. $\endgroup$ – David K Jun 28 '15 at 21:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .