Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In some times I have to set a tag in front of a text math formula. It seems better to define a command \TAG, as $\TAG{Pythagoras' Equation}a^2+b^2=c^2$ to get <Pythagoras' Equation> a^2+b^2=c^2. The \TAG command need fit several conditions:

  1. give a convenience to change the l(r)angle globally;
  2. the content could be broken down, but do not at left angle;
  3. it'd better be put in math mode.

Of course the amsmath \tag command might be modified to suit my demand, but I don't know how to do.

@ TH.: O.K.

  1. Think about an onerous editor who likes green color than black or a pair of parenthese than a pair of angle.
  2. When the content of \TAG is very long, it cannot overlap the right margin, and its suitable break line point mustn't at the left delimiter as most of people want.
  3. The command is in math mode, so it can be affected by \mathsurround, \everymath, etc.

add an image http://i.stack.imgur.com/ZUgVk.png

share|improve this question
    
I don't understand your requirements. Can you give more explanation of what you want? –  TH. Mar 14 '11 at 8:22

2 Answers 2

Here is a \TAG macro that sets its content (assumed to be text) in a parbox of a specifiable width as a tag between customizable delimiters:

\documentclass{article}
\usepackage{amsmath}
\newlength{\tagwidth}
\setlength{\tagwidth}{1in}
\newcommand{\tagldelim}{\langle}
\newcommand{\tagrdelim}{\rangle}
\newcommand{\TAG}[1]{\tag*{$\left\tagldelim\parbox{\tagwidth}{#1}\right\tagrdelim$}}
\begin{document}
\[
\TAG{Pythagoras' Equation}a^2+b^2=c^2
\]
\setlength{\tagwidth}{2in}
\renewcommand{\tagrdelim}{\rbrack}
\[
\TAG{Theory of life, the universe, and everything}
6 \times 9 = 42
\]
\end{document}

enter image description here

share|improve this answer
    
Hey friend, I need use the command in text mode, but not in display math mode; and I want it appear in front of formula. –  user4169 Mar 14 '11 at 15:00
\makeatletter
\providecommand{\textlangle}{$\langle\m@th$}
\providecommand{\textrangle}{$\rangle\m@th$}
\makeatother
\newcommand{\TAG}[1]{%
  $% get out of math mode
  \kern-\mathsurround % get rid of \mathsurround
  \textlangle % start the tag
  \nobreak\hspace{0pt}\textup{#1}% typeset the tag
  \textrangle % end the tag
  ~% insert a non breakable interword space
  \kern-\mathsurround % get rid of \mathsurround
  $% restart the formula
}

The definitions of \textlangle and \textrangle are just for convenience. This works even if you insert formulas with \(...\) or \begin{math}...\end{math}.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.