11
$\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$
7
  • 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
    Commented May 16, 2014 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$ Commented May 16, 2014 at 18:39
  • $\begingroup$ They both show up when i am using my phone... $\endgroup$
    – user1729
    Commented May 16, 2014 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
    Commented Jun 6, 2015 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$ Commented Jun 28, 2015 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
    Commented Jun 28, 2015 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
    Commented May 28, 2017 at 3:29

3 Answers 3

29
$\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[12pt,color:red;border-radius:6px;box-shadow:4px 4px 8px firebrick]{ \verb/click me for hint/} \end{array} }{ \begin{array}{cl} 1. & \text{Define }x \text{ = (complex formula)}\\ & \bbox[12pt,color:red;border-radius:6px;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[12pt,color:red;border-radius:6px;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[12pt,color:red;border-radius:6px;box-shadow:4px 4px 8px firebrick]{
\verb/click me for hint/}
\end{array}
}{
\begin{array}{cl}
1. & \text{Define }x \text{ = (complex formula)}\\
& \bbox[12pt,color:red;border-radius:6px;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[12pt,color:red;border-radius:6px;box-shadow:4px 4px 8px firebrick]{
\verb/That's it, thanks for wasting your time!/}
\end{array}
}
\endtoggle$$
$\endgroup$
8
  • 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$ Commented May 17, 2014 at 1:49
  • 2
    $\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$ Commented May 17, 2014 at 1:55
  • $\begingroup$ This is great, not exactly what I would wish for, but at least partially solves the problem. $\endgroup$
    – dtldarek
    Commented May 21, 2014 at 12:03
  • 1
    $\begingroup$ Guys. Assembly code is more transparent than this!!! $\endgroup$ Commented Jun 28, 2015 at 14:43
  • 1
    $\begingroup$ @Steven: Not if you use the AT&T convention! :-) $\endgroup$
    – Asaf Karagila Mod
    Commented Jun 28, 2015 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
    Commented Jul 26, 2015 at 7:00
  • $\begingroup$ @PhoemueX right click on the piece marked up by MathJAX and then choose "Show Math As --> TeX Commands". $\endgroup$ Commented Jul 26, 2015 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$ Commented May 28, 2018 at 14:29
15
$\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$
3
  • 5
    $\begingroup$ Horrifying, but incredibly awesome. $\endgroup$
    – Asaf Karagila Mod
    Commented Jun 28, 2015 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
    Commented Jun 28, 2015 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
    Commented Jun 28, 2015 at 21:13
2
$\begingroup$

This feature request is outdated!

It’s from the time that spoilers showed when you hovered over them, but only during the hover. Now spoilers show when you click them, and stay visible as long as the page is opened.

(Someone corrected an outdated link and bumped this question to the front page.)

$\endgroup$
1
  • $\begingroup$ So there's no way to hide it again after clicking on it? $\endgroup$
    – mr_e_man
    Commented Feb 1, 2023 at 3:33

You must log in to answer this question.

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