How to demonstrate LaTeX tags and code

  • Context: LaTeX 
  • Thread starter Thread starter jtbell
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around methods for demonstrating LaTeX tags and code within a forum environment, specifically focusing on how to illustrate these tags without rendering them. Participants explore various techniques, including the use of color tags and formatting tricks, to display LaTeX code effectively.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants inquire about methods to illustrate itex and tex tags without rendering them, suggesting the use of extra spaces or specific formatting tricks.
  • One participant mentions a method involving the use of Cyrillic characters to avoid rendering issues, though its effectiveness may vary across different systems.
  • Another participant shares a technique of wrapping LaTeX tags in color tags to prevent rendering, noting that this method does not work inside code tags.
  • Participants discuss the limitations of color tags, indicating that they must be applied individually to each LaTeX command to achieve the desired effect.
  • There is mention of a "Technicolor method" for displaying LaTeX code, though its specifics are not fully detailed.
  • One participant points out that certain LaTeX environments, such as cases, can be displayed without tex tags, but require careful handling to prevent parsing.

Areas of Agreement / Disagreement

Participants express various methods for illustrating LaTeX code, but there is no consensus on a single best approach. Multiple competing views on the effectiveness of different techniques remain unresolved.

Contextual Notes

Some methods discussed depend on specific formatting and may not work universally across all setups. There are unresolved issues regarding the rendering of LaTeX code in different contexts, such as inside code tags versus outside.

jtbell
Staff Emeritus
Science Advisor
Homework Helper
2025 Award
Messages
16,107
Reaction score
8,130
Does this work for illustrating itex and tex tags?

[noparse][itex]E=mc^2[/itex][/noparse]
 
Physics news on Phys.org
Nope. :H

Is there any way to illustrate the use of tags without rendering them, besides inserting extra spaces?

[ itex ]E=mc^2[ /itex ]
 
[ plain] is a new [noparse]. But as the MathJax system knows nothing about UBBC tags and ignores them completely, there is currently no good way of showing these things. You can try the cyryllic trick (replacing standard ASCII e with "е") but on some computers it doesn't render correctly.

[tеx]E=mc^2[/tеx]
 
  • Like
Likes   Reactions: Greg Bernhardt
That's a nice trick! The two e's look identical on my setup (Firefox, Mac OS).
 
Testing another method suggested by mfb in a report thread:

##E=mc^2##

[tex]E=mc^2[/tex]

Yay! The trick is to wrap each tag in color tags, and make them black. If I use red instead:

[tex]E=mc^2[/tex]

Interestingly, the color tags don't show up when you edit or quote the post. o_O

Oh wait, they do show up if you switch to the BBCode editor. Wow, where did all those duplicate color tags come from? oo)

Let's see if I can use the "Text Color" icon in the palette:

[tex]E=mc^2[/tex]

Yep, that works, too. You don't actually have to type out the color tags.
 
Last edited:
Even changing the text color of one letter to black will work.
Here I have changed the 'x' in tex to black.
[tex]E = mc^2[/tex]

Next, I change the 2nd $ of the first pair to black.
$$E = mc^2$$

This might not work if you have subsequent LaTeX stuff, so might need to also change one $ in the end pair.
 
Yes, outside code tags that works fine. Inside it does not.

Color code does not get parsed:
Code:
[itex[/color]]a^2[/itex]

Same with plain (it is simply treated as regular text):
Code:
[plain][itex]a^2[/itex][/plain]

But itex does get parsed:
Code:
[itex]a^2[/itex]
 
Indeed, the color-tag trick does not work inside code tags. However, it does work inside font tags, so you can put an entire code example in e.g. Courier New instead of the default Ariel:

[tex]E=mc^2[/tex]

Now I wonder what happens if I put the entire example in color tags, which is simpler than doing it for the individual tex tags...

[tex]E=mc^2[/tex]

Nope, you have to do the tags individually.
 
Code this work?

Code:
\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)

Code:
##\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)##

Code:
[tex]\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)##[/tex]
 
  • #10
I suppose we could call that the Technicolor method. :cool:
 
  • #11
Is this some plugin, or just XenForo?
 
  • #13
Here's something weird. Consider this code:

[tex] u(x) =<br /> \begin{cases}<br /> \exp{x} & \text{if } x \geq 0 \\<br /> 1 & \text{if } x < 0<br /> \end{cases}[/tex]

which produces this:
[tex] u(x) =<br /> \begin{cases}<br /> \exp{x} & \text{if } x \geq 0 \\<br /> 1 & \text{if } x < 0<br /> \end{cases}[/tex]
If you "colorize" only the [tex]tag, you get this:<br /> <br /> <span style="font-family: 'Courier New'">[tex] u(x) =<br /> \begin{cases}<br /> \exp{x} & \text{if } x \geq 0 \\<br /> 1 & \text{if } x < 0<br /> \end{cases}[/tex]<br /> <br /> To make all the code display as code, you also have to colorize the LaTeX <span style="font-family: 'Courier New'">\begin{cases} command that creates the cases environment. You don't have to colorize the closing <span style="font-family: 'Courier New'">\end{cases} command. This applies to other environments as well (array, matrix, ...).<br /> <br /> You also don't have to colorize the closing </span></span></span>[/tex] tag, just the opening [tex]. I only realized this just now.[/tex]
 
Last edited:
  • #14
\begin{cases}
\exp{x} & \text{if } x \geq 0 \\
1 & \text{if } x < 0
\end{cases}

Things with begin and end get parsed without any tex tags (for whatever reason). Therefore, you have to mask them separately to prevent parsing.
 

Similar threads

  • · Replies 23 ·
Replies
23
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 23 ·
Replies
23
Views
4K
Replies
10
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 5 ·
Replies
5
Views
5K