Tag Info

Hot answers tagged

26

As @whlt3 said it is required if you intend to have a final horizontal line \hline or a partical line via \cline{...} or if you want to have some extra space blow that line produced via the optional argument of \\. If not then it is completely optional. I would however suggest to use \\ on all lines as that allows you to easily add or reorder rows in your ...


20

The most straightforward way of putting something in a framed box is the \fbox command. \documentclass{article} \begin{document} \newcommand{\sep}{\hspace*{.5em}} \noindent $\fbox{5} \sep \fbox{2} \sep \fbox{7} \sep \fbox{-5} \sep \fbox{16} \sep \fbox{12}$ \end{document} Now that does not look very nice, the boxes are differently sized, depending ...


19

It's been a while since I played with NumPy, but I used to call the numpy.savetxt function to export my data as a .csv format: import numpy A = numpy.random.randn(4,4) numpy.savetxt("mydata.csv", A) The sample file mydata.csv was generated accordingly: 1.058690791897618361e-01 4.236767150069661314e-01 -9.871862191240249329e-02 1.896410657805123634e+00 ...


17

The blkarray package allows to do complex border matrix with relatively simple code: \documentclass{article} \usepackage{blkarray} \usepackage{multirow} \begin{document} \[ \begin{blockarray}{cc|cccc|cccc} & 1\dots 18 & 19 & 20 & 21 & 22 & 23 & 24 & 25 & 26 \\ \begin{block}{c(c|cccc|cccc@{\hspace*{5pt}})} ...


16

Here is a sans-tikz approach to typesetting an array. The etoolbox package provides \docsvlist that processes a comma separated value (CSV) list using the element-wise generic \do command that takes one argument. By redefining \do, you can modify the operation performed on/to each element. In the following minimal working example, the ...


16

You don't need to modify sudoku.sty, just to use its infrastructure: we can use the macros as modified by Harish Kumar, but changing their names. In this way you can input both sudoku and shidoku puzzles using a similar syntax. \documentclass{article} \usepackage{sudoku} \makeatletter \newcommand*\@shidoku@grid{ \linethickness{\sudokuthinline}% ...


15

This answer consists of three parts: a solution with manual adjustment of the vertical spacing, a solution with a modified \arraystretch that automatically centers the brackets around the matrix properly (unlike the original \arraystretch!), an explanation of the ugly default spacing. The easy answer You have two issues here: The spacing is ugly ...


14

You can stick some \struts in there (the height+depth of a paren): \documentclass{article} \usepackage{mathtools} \begin{document} \[ \begin{bmatrix} \dfrac{\strut\partial f}{\strut\partial x} \\ \dfrac{\strut\partial f}{\strut\partial y} \end{bmatrix} \] \end{document}


13

Here's a possible solution using a tabular: \documentclass{article} \usepackage{array} \newcolumntype{P}{% >{\rule[-0.6cm]{0pt}{1.5cm}\centering$}p{1cm}<{$}} \begin{document} \noindent\begin{tabular}{!{\vrule width 2pt}P|P!{\vrule width 2pt}P|P!{\vrule width 2pt}} \noalign{\hrule height 2pt} a & b & c & d \tabularnewline \hline a & ...


13

I have modified the sudoku.sty for you and here are the contents of the 4x4 sudoku44.sty file. Save the contents below in the name sudoku44.sty and keep it in the same directory as your .tex file. (Alternatively put the file in C:\Program Files\MiKTeX 2.9\tex\latex\sudoku\ and run a refresh file name data base if on windows.) %% %% This is file ...


12

In the cvs version of pgf/tikz or in the version available for texlive at tlcontrib there is an experimental undocumented dim function in pgfmath defined as \makeatletter % dim function: return dimension of an array % dim({1,2,3}) return 3 % dim({{1,2,3},{4,5,6}}) return 2 \pgfmathdeclarefunction{dim}{1}{% \begingroup \pgfmath@count=0\relax ...


12

This answer may be more generic than specifically relating to TikZ/PGF. (La)TeX is a macro-based language, so it does not work as expected compared to other languages when dealing with "arrays". For example, while \names[2] should yield Laura where \def\names{Katie, Frank, Laura, Joe} (indexing from 0), (La)TeX considers [2] to have no connection to ...


12

The spacing is all wrong if you use an array, the AMS alignments provide alignment whilst preserving operator spacing: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} \begin{array}{ccl} a + b + c & = & d \\ e + f & = & g \\ h & = & i \end{array} \end{equation} ...


12

Here's a solution which (a) uses the align* environment instead of the array environment and (b) inverts the order of the arguments inside the cases environment (as I believe that this may be closer to general usage of this environment). It also defines a macro called \abs to simplify typesetting in the body of the example. \documentclass{article} ...


11

An easy way out here is to nest two array environments: \documentclass{article} \begin{document} \[ A = \left[ \begin{array}{c|c} \begin{array}{@{}c@{}} B \\ a^{T} \end{array} & b \\ \end{array} \right] \] \end{document} Note the use of @{} around the innermost array column specification. This removes the inter-column ...


11

Basic Example: Here is an example of one way to reproduce the Division Algorithm from Page 4 of Grobner Bases and their Applications by Kaitlyn Moran using an array. Notes: multirow was used to center the \sqrt{xy^2 + 1} term in between the two rows. \multicolumn{1}{c}{<text>} was used to center content within a cell Extended Example For the ...


11

The array package allows for inserting tokens at the start of cells: \documentclass{article} \usepackage{array} \usepackage[usenames,dvipsnames,svgnames,table]{xcolor} \begin{document} $ \def\mycolor{} \newcolumntype{R}{>{\mycolor}r} \newcolumntype{C}{>{\mycolor}c} \newcolumntype{L}{>{\mycolor}l} ...


10

It is also relatively easy to solve using just TikZ: \documentclass{article} \usepackage{tikz} \newcounter{arraycard} \def\arrayLength#1{% \setcounter{arraycard}{0}% \foreach \x in #1{% \stepcounter{arraycard}% }% \the\value{arraycard}% } \begin{document} \noindent The length of $\{1,2,3\}$ is \arrayLength{{1,2,3}}.\\ And the length of ...


10

The manual of memoir says that emulated package can be "disemulated", so the instructions \documentclass{memoir} \DisemulatePackage{array} \usepackage{array} should do the job (I omit options and other packages just for the sake of brevity). However, it doesn't seem to work for array, because some errors are raised about already defined things, for ...


10

You can also use the alignat* environment which allows for multiple align points: Notes: The alignat*= environment produces as many rl pairs as specified in the first paramater and does not insert additional space that the align environment does, so you need to insert the space that is desired between the alignment points. The leading & is used to ...


10

You need to specify the array format; for example: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align} \begin{array}{ccc} 1 & 2 & 3\\ 1 & 2 & 3 \end{array} \end{align} \end{document} Some new information has been given in the comments; the problem comes from using the arrayjob and amsmath packages ...


10

Since the contents is a display of math content, I'd suggest a display math environment with some fixed-width separation (like \qquad). Also align the arrays at the top: \documentclass{article} \begin{document} I have two related tables that could naturally be displayed side-by-side but don't have to be. However, it saves space to display them ...


10

The implementation of optional arguments in xparse doesn't want spaces before the last one in order to avoid problems if the call is followed by a bracket that's to be printed. So if you call \[ \optimizationproblemb {minimize} [x \in \mathbf{R}^{n}] {c^{T} x}% <-------------- Don't forget this!!! [\constraint{A x}{=}{b} ...


9

I took @mico's answer and added hhline \documentclass[a4paper,12pt]{report} \usepackage{multirow,hhline} \begin{document} \[ A = \left( \begin{array}{r|rrr||r|l} \hhline{~|---||-|~} \multirow{2}{*}{$B \bigg\{$} & 1 & 2 & -4 & 1 & \multirow{2}{*}{$\bigg\} \hat{\mathbf{b}}^{T}$} \\ & 2 & -5 & -3 ...


9

Working from [SciPy-User] 2d array to Latex: $ python Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy >>> a=numpy.zeros((2,2)) >>> print " \\\\\n".join([" & ".join(map(str,line)) for line in a]) 0.0 & 0.0 \\ 0.0 & 0.0 >>> Add on tabular, table, ...


9

Another solution could be highlight the background of the row. Here I provide a solution based on the \tikzmark macro (basic idea taken from Background coloring with overlay specification in algorithm2e + beamer package). The code: \documentclass{article} \usepackage{amsmath} \usepackage[usenames,dvipsnames,svgnames,table]{xcolor} \usepackage{array} ...


9

You can use a simple tabular and colortbl: \documentclass{article} \usepackage{colortbl} \usepackage{amsmath,amssymb} \begin{document} \begin{tabular}{c@{\,}l@{}} & $p$ \\ \arrayrulecolor{blue} & $p \to q$ \\\cline{2-2} $\therefore$ & $q$ \\ \end{tabular} \end{document} You can change the color of ...


9

Here's another (TikZ-free) option: \documentclass[a4paper,12pt]{article} \usepackage{amsmath} \usepackage{array} \newcommand\undermat[2]{% \makebox[0pt][l]{$\smash{\underbrace{\phantom{% \begin{matrix}#2\end{matrix}}}_{\text{$#1$}}}$}#2} \begin{document} \[ \left ( \begin{array}{rrr|rrr} 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & ...


9

cases only takes one alignment point (that is, it is a two column table) and you have used two on each row. Deleting the extra ones makes it work. Please in future always post complete documents showing all relevant packages (amsmath here). \documentclass{article} \usepackage{amsmath} \begin{document} \[ \begin{array}{rl} p_{Y \mid H_1}(y \mid H_1) & = ...


9

Looks like you have an extra line break \\ to the right of your label. If you delete it, the output should look fine. \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align} \left. \begin{array}{ll} a = b + c \\ & \dots \\ a = b + c \\ & \dots \\ a = b + c \end{array} \right\} \label{formulas} \end{align} \end{document} ...



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