Tag Info

Hot answers tagged

11

A solution with Plain TeX for fun, learning, and to show what's possible with the basic building blocks: \def\widest{000} \def\uv{\unskip\vrule} \def\bx#1#2{\vbox{% \offinterlineskip% \halign{\ \hfil## &##&\ \hfil## \cr \hphantom{\widest}&&\hphantom{\widest}\cr &\vrule\strut& #2\cr ...


6

As far as I know, there is no such package, but it can be achieved with basic setups, using \multicolumn and \cline macros. \documentclass[twoside]{book} \usepackage{booktabs} \usepackage{array} \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}} \usepackage{blindtext} \begin{document} \large \begin{tabular}{|*{8}{L{1cm}|}} \hline & 114 ...


6

You could add the line \xdef\resa{\resa}%% to your code. But things still won't compile properly because your multiplier gets you out of the range from 0 to 1. \documentclass{article} \usepackage{fp,xcolor,colortbl} \FPeval{\resb}{0.5} \newcommand{\he}[1]{% \FPeval{\resa}{2 * #1}% \xdef\resa{\resa}%% \cellcolor[gray]{\resa}% #1 } ...


6

The following example solves the issue by expanding \resa before \cellcolor is expanded and looks at its arguments. The second problem is, the range for the color model gray is between 0 and 1 inclusively. The values 0.8 and 1.0 exceed this, when multiplied by 2. Therefore the example checks the result and limits it to 1 if necessary. ...


6

The macro \macro (sic!) is defined to have an optional argument. If this missing, the call \macro{3}{4} is the same as \macro[]{3} and the figure 4 will be read for the next tabular row. The column shift in the 'wrong' usage is clearly visible. 3 is in the 4th column, instead of the requested 3rd column. \documentclass[a4paper,10pt]{article} ...


5

A simpler solution using expl3 and its powerful fp module. \documentclass{article} \usepackage[table]{xcolor} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\he}{m} { \cellcolor[gray]{ \fp_eval:n { min ( 2*#1, 1 ) } } #1 } \NewDocumentCommand{\hetest}{m} { \cellcolor[gray]{ \fp_eval:n { min ( 2*#1, 1 ) } } \textcolor{red}{#1 ~ -- ~ ...


5

FWIW, this effect is relatively easy to achieve in ConTeXt. Note the very clean separation of content and presentation. \startsetups[cellular] \setupTABLE[frame=off, align={middle,lohi}, offset=0.5em] \setupTABLE[even] [odd][frame=on, offset=0.25em] \setupTABLE[even][even][rightframe=on, bottomframe=on] \setupTABLE[odd] [even][leftframe=on, ...


5

Paul Gessler wrote the Plain TeX solution using \halign. Great. I add another Plain TeX solution using only \hbox \vbox. The main idea is: if there are only fixed-size columns then we needn't to use \halign, but the \hbox to construction is sufficient. \def\bx#1#2{\vbox{\hbox to4em{\hss\vbox{% \hbox ...


5

A new line is a space. A space is a space. Use % signs to end lines when spaces are not wanted. For example: \documentclass{report} \usepackage{etoolbox} \begin{document} \newcommand{\siglines}[1][coop]{% \begin{tabular}{@{}l} \\\hline Student\\ \\ \\\hline \ifstrequal{#1}{coop}{Employer Thesis ...


4

Normally you break after operators in inline math (to show the expression carries over) and before operators in an aligned display, where it is essentially a new expression aligned on the first. Here inline math is being used as a convenience to get automatic breaking but arguably it should align like a display, so make = into an active character that ...


4

\documentclass{scrartcl} \usepackage{tikz} \tikzset{/bowlinggrid/.cd, box width/.store in=\bgridlargewidth,box width=3cm, box height/.store in=\bgridlargeheight,box height=2.5cm, small width/.store in=\bgridsmallwidth,small width=1.2cm, small height/.store in=\bgridsmallheight,small height=1cm, columns/.store in=\bgridcolnumber,columns=4} % I ...


4

Here you go. \documentclass{article} \usepackage{multirow,bigdelim} \begin{document} Text goes here \begin{description} \item[\texttt{bigdelim}] \begin{itemize} \item[] \item[Sub-Thing:] Text goes here \item[Sub-Thing:] \begin{tabular}{r@{}cl} ...


3

Use \makebox instead of the \kern: \documentclass{article} \usepackage{array} \newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}} \begin{document} \begin{tabular}[h]{|M{1in}|M{1in}|M{1in}|} %\begin{tabular}[h]{|c|c|c|} \hline \rule{0.2in}{1in} & \rule{1in}{0.2in} & \rule{0.2in}{1in} \\ \hline \rule{1in}{0.2in} & ...


3

I would try to avoid scaling tables, and avoid using tabularx for numeric data (tabularx adjusts column widths by changing the target width for line breaking but you don't normally want line breaking within cells for this kind of table) \documentclass{beamer} \usepackage[english]{babel} \usepackage{tabularx,booktabs,dcolumn} ...


3

I think you have two good choices and a (likely) dreadful choice: Use a tabular* environment, Use a tabularx environment (or its close cousin, tabulary) Use the basic tabular environment and scale it up (or down) using \resizebox. The results are as follows (the first horizontal line is there just to illustrate the width of the text block): Can you ...


3

David is referring to the m-specifier in \newcolumntype{M}{>{\centering\arraybackslash}m{\dimexpr.096\linewidth-2\tabcolsep}} How about a layout like this: \documentclass[a4paper,10pt]{article} \usepackage{tabularx,booktabs,geometry} \geometry{textwidth=15cm} \begin{document} \noindent \footnotesize ...


3

I wouldn't use the m column type for this table. In its place, I would use a centered form of the X column provide (provided by the tabularx package), in part to let LaTeX handle the chores of determining column widths. Separately, I'd use the line-drawing macros of the booktabs package to get well-spaced horizontal lines; plus, I'd omit all vertical lines. ...


3

If you want the macro without the optional argument: \documentclass[a4paper,10pt]{article} \newcommand{\macro}[2]{% notice the lack of the second brackets here & something & #2 & #1 \\ } \begin{document} \begin{tabular}{lccc} \macro{3}{4} \end{tabular} \end{document}


2

Here's an attempt following the guidelines of booktabs for professional tables and siunitx for alignment of the numerical data. Note that braces ({...}) are used to escape the contents of cells that do not contain numbers to be aligned. \multicolumn also serves this purpose for those cells. Allowing space for the minus sign in the alignment is a matter of ...


2

The OP is missing a \\ before the last \tabucline command. Any table package I know requires a \\ (apart from the first line) for \hline - like statements (unless multiple of them occur in a row) For my taste there are too much lines in the table. \documentclass[11pt,a4paper,twoside,openright]{report} %\usepackage{setspace} % not needed ...


2

With standard LaTeX methods, also with a friendly syntax. The trick is to nest tabular environments. \documentclass{article} \newlength{\blockwidth} \AtBeginDocument{\settowidth{\blockwidth}{0000}} \newcommand{\block}[2]{% \begin{tabular}{@{}c|c@{}} & \makebox[\blockwidth][r]{#2\enspace} \\ \cline{2-2} ...


2

With a possibly handy syntax: the avs environment takes as optional argument the column specifier for the second column (default l); it should contain one or more \avsline commands; the optional argument is meant to specify a color. Some auxiliary macros are defined for easing specification of symbols. \documentclass{article} ...


2

You can use \multirow and some spacing hacks to get this result (see first table below), but without knowing more about your data it's hard to see how this would help the reader. It might be clearer to rotate your table, as in the second example below, which also uses the booktabs package for (arguably) more attractive table formatting. Note that \bf is ...


2

Not sure to understand the question, but something like this? \documentclass{article} \usepackage{multirow} \usepackage{amsmath,amssymb} \begin{document} \begin{center}\begin{tabular}{|c|c|c|c|} \hline \multicolumn{4}{|c|}{\bf title}\\ \hline \hline \bf s1 & \bf s2 & \bf s3 & \bf s4\\ \hline \hline \multirow{4}{*}{$\varnothing$} ...


2

With some help from xparse (to easily define a \source command with a *-variant) and array for a new column type: \documentclass{article} \usepackage{xparse,array} \NewDocumentCommand{\source}{sm}{% \IfBooleanTF{#1}{\bracedsource{#2}}{#2 &}% } \NewDocumentCommand{\bracedsource}{m}{% \global\setbox9=\hbox{% ...


2

You can use the table-format option, to specify how much space to set aside for each part of the numbers in the table. If you have integers of up to, say, 3 digits, you can use table-format=3 to set aside space for 3 integer digits, and no decimals. As stated in the comments, this option can also be set on a per-column basis, by passing the options to the ...


2

This has absolutly nothing to do with the way the chessboard is build. The chessboard is like e.g. a graphic simply a box with the baseline at the bottom and so allmost all answers concerning the alignment of graphics with text (see e.g. How to vertically center text with an image in the same row of a table) can be used in this case too: You can use ...


2

Smaller version with less lines and typographical fixes: \documentclass{article} \usepackage{array} \usepackage{booktabs} \begin{document} \begin{table} \centering \begin{tabular}{>{Pin }l<{:}@{ }l>{Pin }l<{:}@{ }l} \toprule \multicolumn{2}{l}{JP1/JP14, Pins 1--8} & \multicolumn{2}{l}{JP1/JP14, Pins 9--16} \\ ...


2

Here's the revised version. Changes: Fixed your newcolumntype. I also had fixed the command for the \tabnode, but this solution didn't allow the numbers inside the node to align by the decimal separator so I removed the command altogether and replaced with something else, see below. Furthermore, now if you try adding random numbers to your values, they ...


1

It is not clear, what "incomplete" means. Assuming, that the table extends horizontal dimension, we can correct it, tightening the columns (option [H] removed, because it needs an additional package): \documentclass{article} \begin{document} \begin{table} \begin{tabular}{|c|c|c|c|} \hline %\rule[-1ex]{0pt}{2.5ex} JP1/JP14 Pins 1 – 8 & Description ...



Only top voted, non community-wiki answers of a minimum length are eligible