Math & ScienceCentered Indices (left, top, right, bottom)

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
czeidler
Posts: 2
Joined: Thu Jan 31, 2013 12:13 am

Centered Indices (left, top, right, bottom)

Post by czeidler »

Hi,

for my project I'm using a special notation for some layout items. For example, to display the connections of an item A I write:
$$\prescript{t}{l}{A}^b_r$$

However, while left (l) and right (r) are on the left and right of A the top (t) and bottom (b) are both upper indices.

What I'm looking for is a way to display all indices at intuitive positions, i.e. l is left beside A, t is centred on the top, r is right beside A and b is centred below A.

The attachment shows what I got at the moment (top) and what I want to have (below).
Attachments
Indices.png
Indices.png (1.68 KiB) Viewed 5548 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Centered Indices (left, top, right, bottom)

Post by Stefan Kottwitz »

Hi,

welcome to the board!

Better use \[...\] instead of $$...$$. The latter is TeX syntax, not LaTeX, and can result in bad vertical spacing.

Here's a possible solution. I used \overset and \underset of amsmath, and defined \vc for vertical centering.

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\newcommand*{\vc}[1]{\vcenter{\hbox{#1}}}
\newcommand*{\notation}[5]{%
  \vc{\scriptsize$#2$}\overset{\;#1}{\underset{#3}{\vc{$#5$}}}
  \vc{\scriptsize$#4$}
}
\begin{document}
\[
\notation{t}{l}{b}{r}{A}
\]
\end{document}
notation.png
notation.png (2.58 KiB) Viewed 5545 times
Stefan
LaTeX.org admin
czeidler
Posts: 2
Joined: Thu Jan 31, 2013 12:13 am

Re: Centered Indices (left, top, right, bottom)

Post by czeidler »

awesome! thanks for the example! works very nice and I even understand the code :-)
Post Reply