For numbers:
There are some packages, like siunitx
and math engine of tikz
(especially in pgfplotstable
), which can used to format numbers in LaTeX. numprint
may be the simplest one, and can be easily used in tabulars.
numprint
package privides n
and N
column types for numbers in tabular, and \nprounddigits
for set the precision. An example:
% \usepackage{numprint} in preamble
\npdecimalsign{.}
\nprounddigits{2}
\begin{tabular}{c|n{5}{2}|}
foo & 12345 \\
bar & 12345.12345 \\
baz & 0.00012345 \\
\end{tabular}
\npnoround
Please read the manual for more options.
For common characters, @TH has showed some TeX trick. However, you can use xstring
package or something else to do the dirty work. I don't know how to get full control in tabular
, so here is just a incomplete solution, a mix of xtring
and primitive TeX:
\halign{\StrLeft{#}{4} \cr
abc \cr
abcde \cr
abcdefg \cr
}
Any further suggestions are welcome.
There is a standard. It's a matter of opinion whether it's sensible or not, but it's been there since the release of LaTeX2e.
Font aspect changing commands have two forms: action and declaration
The same holds for abstract instruction such as "emphasize"
Size changing commands have only the declarative form.
Let me review the three points.
Font aspect changing commands
The declarative form for changing the font's aspect is formed from a prefix denoting briefly the purpose and by a suffix denoting the attribute that's changed:
\sffamily
\itshape
\bfseries
The "action form" is a command that takes an argument; all kernel defined commands of this type have a prefix text
and a suffix corresponding to the similar declaration:
\textsf{words}
\textit{words}
\textbf{words}
The fundamental difference is that a declaration's scope is up to the end of the group in which it's issued (or a countermanding declaration).
Two important commands are \textnormal
(action) and \normalfont
(declaration) that instruct LaTeX to use the font which was current at document start.
Abstract instruction
By "abstract instruction" I mean \emph
and \em
, which usually act by italicizing, but one should not rely on this, as the effect can be redefined by the document class.
The form \emph
is the action: \emph{words}
, while \em
is a declaration. The latter can be useful in defining environments.
Size changing commands
The size changing commands have only the declarative form, as very rarely one needs to set a couple of words in a smaller or larger size. Examples
\footnotesize
\small
\normalsize
\large
Their scope ends with the group where they have been issued (usually an environment). If a paragraph must be typeset in a different size it's important to remember marking explicitly the end with \par
or a blank line. Commonly it's the environment where they are issued that takes care of it.
Best Answer
$d=\{3, 2, 2, 1, 1, 1\}$
should do the trick