Text FormattingTrue align ding number with baseline of text

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

True align ding number with baseline of text

Post by cgnieder »

Do you mean like this?

Code: Select all

\documentclass{scrartcl}
\usepackage{chemmacros}
\newcommand{\ci}[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=1pt] (char) {#1};}}
\begin{document}

\begin{alignat*}{1}
 (-1)\times \ci{1}& ~ \ce{H2O + KCl -> NH2 + CO2} \\
           \ci{2}& ~ \ce{H2O -> CO3 + H3O+}
\end{alignat*}

\newreaction[arg,star]{reactionat}{alignat}
\begin{reactionat*}{1}
 (-1)\times \ci{1}& ~ H2O + KCl -> NH2 + CO2 \\
           \ci{2}& ~ H2O -> CO3 + H3O+
\end{reactionat*}

\end{document}
site moderator & package author

Recommended reading 2024:

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

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

ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Re: True align ding number with baseline of text

Post by ghostanime2001 »

You are highly skilled sir, how long have you been doing latex for?
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: True align ding number with baseline of text

Post by cgnieder »

Please don't call me sir, that makes me feel old... ;)

I'm really not that skilled -- there are far more experienced users and programmers out there. I'm still in the learning process. But then ... one always is, right?
It might be about eight years ago when I wrote my first document with LaTeX, I'm not quite sure...
site moderator & package author
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Re: True align ding number with baseline of text

Post by ghostanime2001 »

I started in highschool but didn't get far this summer is when i really wanted to compile my homework as much as possible to save space.
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Re: True align ding number with baseline of text

Post by ghostanime2001 »

How do you put the alignat* into a tabular or array environment because I want to use \hline together with the booktabs package.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

True align ding number with baseline of text

Post by cgnieder »

I would use a simple tabular for that:

Code: Select all

\documentclass{article}
\usepackage[version=3]{mhchem}
\usepackage{tikz,array,booktabs}
\newcommand{\ci}[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=1pt] (char) {#1};}}
\begin{document}

\setlength\extrarowheight{3pt}
\begin{tabular}{>{$}r<{$}rl}
 (-1)\times \ci{1} & \ce{CO + 1/2 O2 -> CO2} \\
           \ci{2} & \ce{C + O2 -> CO2} \\\midrule
                  & \ce{C + 1/2 O2 -> CO}
\end{tabular}

\end{document}
site moderator & package author
Post Reply