How to demonstrate LaTeX tags and code

  • LaTeX
  • Thread starter jtbell
  • Start date
In summary: This works for me. The only thing I would add is an explicit "color" statement at the beginning and end of the code block so I don't have to remember to add it.In summary, there is no good way to illustrate the use of itex and tex tags without rendering them, besides inserting extra spaces.
  • #1
jtbell
Staff Emeritus
Science Advisor
Homework Helper
15,929
5,747
Does this work for illustrating itex and tex tags?

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

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

[ itex ]E=mc^2[ /itex ]
 
  • #3
[ 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 Greg Bernhardt
  • #4
That's a nice trick! The two e's look identical on my setup (Firefox, Mac OS).
 
  • #5
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:
  • #6
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.
 
  • #7
Yes, outside code tags that works fine. Inside it does not.

Color code does not get parsed:
Code:
[ite[color=black]x[/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]
 
  • #8
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.
 
  • #9
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) =
\begin{cases}
\exp{x} & \text{if } x \geq 0 \\
1 & \text{if } x < 0
\end{cases}
[/tex]


which produces this:
[tex]
u(x) =
\begin{cases}
\exp{x} & \text{if } x \geq 0 \\
1 & \text{if } x < 0
\end{cases}
[/tex]
If you "colorize" only the [tex] tag, you get this:

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


To make all the code display as code, you also have to colorize the LaTeX \begin{cases} command that creates the cases environment. You don't have to colorize the closing \end{cases} command. This applies to other environments as well (array, matrix, ...).

You also don't have to colorize the closing [/tex] tag, just the opening [tex]. I only realized this just now.
 
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.
 

1. What is LaTeX and why is it used?

LaTeX is a typesetting language used for creating high-quality documents, particularly in the fields of mathematics, science, and academia. It allows users to format text and equations in a precise and professional manner, making it the preferred choice for technical writing and publishing.

2. How do I show the code for a LaTeX equation?

To display the code for a LaTeX equation, enclose it within two dollar signs ($$) at the beginning and end of the equation. For example, to show the code for the equation x^2 + y^2 = z^2, you would type $$x^2 + y^2 = z^2$$.

3. What are some common LaTeX tags used for formatting?

There are various LaTeX tags that can be used for formatting, such as \textbf{} for bold text, \emph{} for emphasis, \underline{} for underlined text, and \frac{}{} for fractions. It is recommended to refer to a comprehensive LaTeX guide for a complete list of tags and their usage.

4. How do I include images and tables in a LaTeX document?

To include images in a LaTeX document, use the \includegraphics{} tag and specify the file name and location of the image. For tables, use the \begin{tabular}{} and \end{tabular} tags to create a table structure, and use & to separate columns and \\ to separate rows.

5. Can I use LaTeX for creating presentations?

Yes, there are packages such as Beamer that allow users to create presentations in LaTeX. These packages provide templates and commands for creating slides, adding images and animations, and customizing the overall layout and design of the presentation.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
23
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
919
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
16
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
23
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
862
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
412
Back
Top