Dear All,
I need to define a couple of new mathematical symbols.
The first should basically be a triangle with a small text written in the middle. For example: The new command $\deltaop{p+1}$ should typeset a $\triangle$, appropriately scaled to fit the text $p+1$, which should in turn be correctly centered.
The second is "--oo", i.e. a line with two circles, which each should contain a small integer or a single letter. I.e. $f: X \mlto{3}{2} Y$ (meaning, for the sake anyone curious, "f is a multilinear map from X to Y of contravariant rank 3 and covariant rank 2") should typeset "f: X --(3)(2) Y$ with 3 and 2 positioned at the center of the circles, and the circles appropriately sized to fit the text.
I've basically done this through extremely painful trial and error using \raisebox and negative \hspace and whatnot, yielding an somewhat acceptable but terribly fragile result: If text size is changed, or if the wind blows the wrong way, it will completely screw up.
Searching on google for "defining new symbols in latex" and multiple variants thereof mostly yields references to predefined symbols, and I've been completely unable to find good pointers on what the kosher way is to define "robust" mathematical symbols in LaTeX. And MetaFont seems (correct me if I'm wrong) not to solve the problem, since I need the symbols to fit dynamic text.
Any help will be well and truly appreciated!
Thanks in advance.
Math & Science ⇒ Defining new symbols in a robust manner
NEW: TikZ book now 40% off at Amazon.com for a short time.

Defining new symbols in a robust manner
Hi,
the first idea that comes to my mind is to use the PGF/TikZ package (specially all the features that it provides to handle nodes); refer to the PGF manual for further information. Please have a look at the following example:
Of course, it is just an example, and it admits improvements. I think that the triangle issue can be handled analogously.
the first idea that comes to my mind is to use the PGF/TikZ package (specially all the features that it provides to handle nodes); refer to the PGF manual for further information. Please have a look at the following example:
Code: Select all
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newcommand*\myco[2]{%
\raisebox{-5pt}{%
\begin{tikzpicture}
\node (a) {\rule{8pt}{.4pt}};
\node [circle,draw,right=-3pt of a] (b) {#1};
\node [circle,draw,right=0pt of b] (c) {#2};
\node [right=-3pt of c] (d) {};
\end{tikzpicture}}}
\begin{document}
text text text text $f:X\myco{3}{2}Y$ text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Defining new symbols in a robust manner
Excellent! Thanks a lot! This works great. I can see that it will really be worth while to take the time to learn PGF/TikZ.
For completeness, here is the solution to my problem. It could probably be cleaned up a bit, but it seems to work pretty well.
The result is in the attachment.
Thanks again! It was a really big help.
For completeness, here is the solution to my problem. It could probably be cleaned up a bit, but it seems to work pretty well.
Code: Select all
\documentclass{article}
\usepackage{pgf,amsmath,tikz,type1cm,fix-cm}
\usetikzlibrary{positioning}
\newlength{\XHeight}
\newlength{\XWidth}
\newcommand*\mlto[2]{% Multilinear mapping
\ensuremath{
\settowidth{\XWidth}{$\rightarrow$}
\setlength{\XWidth}{.7\XWidth}
\begin{tikzpicture}
\node [circle,scale=0.4,draw,right=\XWidth] (b) {#1};
\draw (0,0)--(b);
\node [circle,scale=0.4,draw,right=0pt of b] (c) {#2};
\node [right=-4pt of c] (d) {};
\end{tikzpicture}
}
}
\newcommand*\lto{% Linear mapping
\ensuremath{%
\settowidth{\XWidth}{$\rightarrow$}%
\setlength{\XWidth}{.7\XWidth}
\begin{tikzpicture}
\node (a) {\rule{\XWidth}{.4pt}};
\node [circle,draw,scale=0.4,right=-3pt of a] (b) {};
\node [right=-4pt of b] (c) {};
\end{tikzpicture}
}
}
\newcommand*\deltahom[1]{\ensuremath{
\settowidth{\XWidth}{#1}
\addtolength{\XWidth}{.4em}
\setlength{\XHeight}{\XWidth}
\tikz[baseline]{
\draw (0em,-.3\XHeight) -- (.5*\XWidth,.7\XHeight) -- (\XWidth,-.3\XHeight) -- (0em,-.3\XHeight);
\node at (0.5\XWidth,0)[scale=0.5] {$#1$};
}
}
}
\begin{document}
Lorem ipsum dolor sit $f:X \mlto{2}{2} Y$, consectetur adipiscing elit. Praesent luctus
\[g: Y\mlto{m}{n}Z\]
suscipit erat. In eget tortor ac nisi pulvinar $f:(X\lto Y)\lto(X\lto Y)$ posuere. Donec urna sapien, congue vitae, dignissim non, dapibus non, nulla. Aliquam ac ligula. Nulla facilisi. Aliquam erat volutpat. Etiam quis enim. Duis auctor leo feugiat nisl. Quisque tellus. Nullam at quam at felis cursus egestas. Cum sociis natoque penatibus
\[
\deltahom{0} = 1,\ \ \ \
\deltahom{p+1} =
\begin{bmatrix}
\deltahom{p} & 0 \\
0 & 0
\end{bmatrix}
\]
et magnis dis parturient montes, nascetur ridiculus mus. Donec varius. Mauris vitae lectus. Sed justo arcu, sagittis a, laoreet sed, fermentum a, tellus. Vestibulum dapibus.
\end{document}
Thanks again! It was a really big help.
- Attachments
-
- tegn.pdf
- (19.06 KiB) Downloaded 790 times