I'm trying to recreate something like this:
However, using basic alignment, I can't recreate this. How would I go about recreating that image (ignoring font)?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI'm trying to recreate something like this:
However, using basic alignment, I can't recreate this. How would I go about recreating that image (ignoring font)?
One option is to stack the fractions (here the <item>
) above the letters (here the <anchor>
) using \stackon[<stacklength>]{<anchor>}{<item>}
from the stackengine
package.
(Improvements to code thanks to comments by @Steven B. Segletes)
As an example:
\documentclass{article}
\usepackage{amsmath}
\usepackage{stackengine}
\setstackgap{S}{14pt}
\begin{document}
\stackon{A}{$\dfrac{17}{19}$}
\stackon{B}{$\dfrac{78}{85}$}
\stackon{C}{$\dfrac{19}{51}$}
\stackon{D}{$\dfrac{23}{38}$}
\stackon{E}{$\dfrac{29}{33}$}
\stackon{F}{$\dfrac{77}{29}$}
\end{document}
gives
;^)
, but a slight quibble. The default stack type is short (S
), so using \Lstackgap
is not really the appropriate measure to use. Rather, you could state something like \setstackgap{S}{14pt}
prior to the initial \stackon
and then omit the optional arguments altogether. As a further upgrade, consider using the tabstackengine
package, and you could set the whole array with a single \tabbedstackon
!
Dec 14, 2017 at 11:15
tabstackengine
sounds interesting, I'll have to take a look at it later! :)
I have just learned LaTeX, but I think for your question, you can use the tabular environment to do it. Here is my example for it.
\documentclass[12pt, letterpaper]{article}
\usepackage{amsmath}
\begin{document}
\begin{tabular}{c c c c c}
$\frac{17}{91}$ & $\frac{17}{91}$ & $\frac{17}{91}$ & $\frac{17}{91}$ & $\frac{17}{91}$ \\[10pt]
A & B & C & D & E \\
\end{tabular}
\end{document}
And it looks like this,
So the idea is to align with tabular, with invisible vertical and horizontal lines.
Details of the tabular environment can be referred from page 43 of The Not So Short Introduction to LaTex 2e.
Hope this helps!
Sen
S
column specifier to align numbers, see sections 4.6 and 5.14, especially the table-format
key on page 47f. The booktabs documentation summarizes how to design formal tables: "(1) Never, ever use vertical rules. (2) Never use double rules. [...]".
A simple array
is enough. I didn't write all the fractions because, since you didn't provide a minimal working example (MWE), it is a bit boring. I let the completion to you.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{array}{*{14}{c}}
\dfrac{17}{91} & \dfrac{78}{85} & \dfrac{19}{51} & \dfrac{23}{38} & \dfrac{29}{33} & & & & & & & & & \dfrac{55}{1} \\[10pt]
\text{A} & \text{B} & \text{C} & \text{D} & \text{E} & \text{F} & \text{G} & \text{H} & \text{I} & \text{J} & \text{K} & \text{L} & \text{M} & \text{N} \\
\end{array}
\]
\end{document}
For example, you can try something like this:
\def\xoy #1/#2 #3 {\vbox{\baselineskip=22pt
\halign{\hfil$\displaystyle{##}$\hfil\cr #1\over#2\cr \rm#3\cr}}\quad}
\noindent
\xoy 17/91 A
\xoy 78/85 B
\xoy 19/51 C
\xoy 23/38 D
\xoy 29/33 E
\xoy 77/29 F
\xoy 95/23 G
\bye