2

Hey I'm trying to align text. I've searched for a while and have tried different variations of codes. Could someone help me out please? I haven't found all too many relevant examples, or at least relevant examples that I understand.

\begin{footnotesize}
\hspace*{-10mm}
\fbox{ \begin{minipage}{0.45\textwidth}
\begin{tabular}{rl}
\emph{\textbf{Oxygen}} &    \emph{\textbf{Silicon}} & \emph{\textbf{Aluminum}} & \emph{\textbf{Iron}} & Calcium & Sodium & Potassium & Magnesium    \\
\emph{\textbf{50\%}} &  \emph{\textbf{26\%}}        &  \emph{\textbf{7.6\%}} &  \emph{\textbf{4.7\%}} & 3.5\%   &   2.7\%   &   2.6\%   &   2.0\%   \\
\end{tabular}
\end{minipage}
}
\end{footnotesize}

I've also tried this code;

\begin{footnotesize}
\hspace*{-10mm}
\fbox{ \begin{minipage}{0.45\textwidth}
\begin{tabbing}{rl}
\=\emph{\textbf{Oxygen}} \= \emph{\textbf{Silicon}} \= \emph{\textbf{Aluminum}} \= \emph{\textbf{Iron}} \= Calcium \= Sodium \= Potassium \= Magnesium  \tabularnewline
\>\emph{\textbf{50\%}} \>  \emph{\textbf{26\%}}         \>  \emph{\textbf{7.6\%}} \>    \emph{\textbf{4.7\%}} \>    3.5\%   \>  2.7\%   \>  2.6\%   \>  2.0\%   \tabularnewline 

\end{tabbing}
\end{minipage}
}
\end{footnotesize}

Please help. If you could please use the top code, as i'm somewhat more familiar with that code. Thank you!!!>

edit* Well this example worked. And these are the packages and definitions being used. I don't quite know which package does what. I mostly use templates and add packages as I go along. This example should compile.

\documentclass[paper=a4, fontsize=11pt]{scrartcl} % A4 paper and 11pt font size
\usepackage{paralist}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage{fourier}
\usepackage{lipsum}
\usepackage{sectsty}
\usepackage{fancyhdr}

\begin{document}
\begin{footnotesize}
\hspace*{-10mm}
\fbox{ \begin{minipage}{0.45\textwidth} 
\begin{tabular}{rl}
Symbol:& Ti \\          
Atomic Number:& 22\\
Specific Gravity:& 4.51 \\ 
Crystal Structure:& HCP\\
Melting temperature:& 1668$^{\circ}$C (3034$^{\circ}$F) \\ 
Elastic Modulus:& 117,000 MPa (7 $\times$ 17$^6$ lb/in$^2$)\\
\end{tabular}
\end{minipage}

\begin{minipage}{0.65\textwidth}
\begin{tabular}{rl}
Extracted from:& Rutile TiO$_2$ and Ilmenite FeTiO$_3$  \\          
Alloying elments:& Aluminum, tin, copper and magnesium
\\  Typical Applications :& Jet engine components, other aerospace 
\\ & applications, prosthetic implants. 

\end{tabular}
\end{minipage}}\newline\newline
\end{footnotesize}
\end{document}

What it is I really want for the top example is for the percentages to align beneath the elements. I want the atomic elements to be horizontally aligned with the percentages beneath. I don't want a table, but I do want the box to surround the text. Could it be possible I'm missing a package? The last codeblock or one I just entered now works, but it's not the alignment I want... Thank you for looking.

  • What kind of vertical alignment you are looking for? – user11232 Oct 4 '15 at 6:31
  • @ReadyF4i, your please upgrade your examples so that one can copy them an compile. The forst example has errors in number of columns, definition of columns headers and they should not be fit in half document width, even full text width is not enough ... – Zarko Oct 4 '15 at 6:40
  • Welcome to TeX.SX! It is easier to help you if you add a minimal working example that takes the form \documentclass{...}\usepackage{....}\begin{document}...\end{document}. If possible, it should compile and have the minimum amount of code needed to illustrate your problem. This makes it much easier for people to troubleshoot your problem - and much more likely that they will! – Andrew Oct 4 '15 at 6:52
  • I have editted the body of the text and added more information as to what the wanted outcome is. – ReadyF4i Oct 4 '15 at 7:20
4

Are you looking for either the following two looks?

enter image description here

\documentclass[paper=a4, fontsize=11pt]{scrartcl}
\usepackage{geometry}
\usepackage{array,fourier}
\usepackage{hyperref}

\newcommand\embf{\em\bfseries}  % handy shorthand macro

\begin{document}
\noindent maybe this?\strut

\noindent
\begin{footnotesize}%
\fbox{\begin{tabular}{*{8}{l}}
\emph{\textbf{Oxygen}} & \emph{\textbf{Silicon}} & 
\emph{\textbf{Aluminum}} & \emph{\textbf{Iron}} &
Calcium & Sodium & Potassium & Magnesium    \\
\emph{\textbf{50\%}} &  \emph{\textbf{26\%}} &  
\emph{\textbf{7.6\%}} &  \emph{\textbf{4.7\%}} & 
3.5\%   &   2.7\%   &   2.6\%   &   2.0\%   \\
\end{tabular}}
\end{footnotesize}

\bigskip
\noindent or this?\strut

\noindent
\begin{footnotesize}%
\fbox{%
\begin{tabular}{*{4}{l}}
\embf Oxygen & \embf Silicon & \embf Aluminum & \embf Iron \\
\embf 50\% & \embf 26\% & \embf 7.6\% & \embf 4.7\% \\
\end{tabular}}%
\begin{tabular}{*{4}{l}}
Calcium & Sodium & Potassium & Magnesium \\
3.5\%   & 2.7\%  & 2.6\%     & 2.0\%     \\
\end{tabular}
\end{footnotesize}

\end{document}
  • @ReadyF4i - Glad one of the two possibilities works for you. Incidentally, if you need the second row to be centered rather than left-aligned relative to the first row, simply replace \begin{tabular}{*{8}{l}} with \begin{tabular}{*{8}{c}}. – Mico Oct 4 '15 at 8:10
3

Even with your MWE is not very clear what you like to achieve.I first a bit reorder your code to show, where is problem:

enter image description here

At the first table the outer frame is produced by frame, the inner which protrude with table out of outer frame, belong to table. Similar mismatch is at second table to. And from above image is not clear (to me), what you like vertical centered.

For start I suggest:

  • write tables with normal size of font
  • to fit first table into text width use chemical symbols instead of their names (this make table narrowed)
  • omit frame and minipages
  • merge tabular's in second frame in one table so, that contents of second one follows to the first one

  • put tables in center environment (or in table floa with \centerin position in the float)

Considering aforementioned, the look-out of (this part) document is:

enter image description here

Code:

\documentclass[fontsize=11pt]{scrartcl}
    \usepackage[a4paper]{geometry}
    \usepackage{siunitx}
    \usepackage{amsmath}
    \usepackage{array,tabularx}
    \renewcommand{\arraystretch}{1.5}%1.2
    \setlength{\tabcolsep}{3pt}

    \usepackage{showframe}

    \begin{document}
    first table
    \begin{center}
\begin{tabular}{|*{3}{>{\itshape\bfseries}c}*{5}{c}|}
    \hline
O   &   Si   &   Al  &   Fe  &   Ca &   Na  &   K   &   Mg  \\
50\,\%
    &  26\,\%
            &  7.6\,\%
                &  4.7 \%
                    &   \SI{3.5}{\%}
                        &   \SI{2.7}{\%}
                            &   \SI{2.6}{\%}
                                &   \SI{2.0}{\%}            \\

    \hline
\end{tabular}
    \end{center}


\bigskip

second table

\begin{center}
\begin{tabularx}{0.8\textwidth}{|rX|}
    \hline
Symbol:& Ti \\
Atomic Number:& 22\\
Specific Gravity:& 4.51 \\
Crystal Structure:& HCP\\
Melting temperature:& \SI{1668}{\celsius} (\SI{3034}{\degree F})    \\
Elastic Modulus:& \SI{117,000}{MPa} ($7 \times 17^6 \text{lb/in}^2$)\\[1em]
Extracted from:& Rutile TiO$_2$ and Ilmenite FeTiO$_3$  \\
Alloying elments:& Aluminum, tin, copper and magnesium  \\
Typical Applications :& Jet engine components, other aerospace applications, prosthetic implants.\\
    \hline
\end{tabularx}
    \end{center}
    \end{document}

In above code I add three package: siunitx for values with measuring units, array and tabulary for tables. I also suggest to look into some chem package for simple writing of chemical elements and materials (i'm not familiar with them).

Is this help?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.