Text Formattingheight of text using \makebox

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

height of text using \makebox

Post by ghostanime2001 »

How can I set the height of C with the height of H+ ?

I have already defined a new lenght \co as the height of H+ but it doesn't work with \makebox even though \makebox can take \height or \totalheight as an optional argument.

Code: Select all

\documentclass{article}
\usepackage[version=3]{mhchem}
\newlength{\co}
\settoheight{\co}{\ce{H+}}
\begin{document}
\fbox{\makebox[\co]{C}} \fbox{\ce{H+}}
\end{document} 

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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

Re: height of text using \makebox

Post by ghostanime2001 »

Any suggestions ?
User avatar
NoIdeaNickanme
Posts: 13
Joined: Wed Nov 09, 2011 5:41 pm

height of text using \makebox

Post by NoIdeaNickanme »

Hi!
This may not be a conventional solution, however using tabular environment and \hhline within a \makebox does the trick.

Code: Select all

\documentclass{article}
\usepackage[version=3]{mhchem}
\usepackage{hhline}
\begin{document}

\makebox{
     \begin{tabular}{|c|}
     \hhline{-}
     C\\
     \hhline{-}
     \end{tabular}
}
\makebox{
     \begin{tabular}{|c|}
     \hhline{-}
     \ce{H+}\\
     \hhline{-}
\end{tabular}
}

\end{document}
If you still have problems with height, use tabulary environment instead.
Post Reply