# Tag Info

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 ...

26

I ran your code but it appeared to be very slow, I suspect from all the \pgfmathtruncatemacro. But here we can do all calculations with \numexpr easily. This code is based on the TeX primitives \ifnum, \ifcase and \csname..\endcsname. I have used \foreach loops in the first two code samples as I wanted to stay close to your original framework. In the third ...

22

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 ...

22

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 ...

19

Just for fun (but perhaps it can be useful to anyone), there is my Lua solution: Main TeX file \documentclass{article} \usepackage{pgffor} \usepackage{xcolor} \usepackage{courier} % Courier has bold series, while cm doesnt \usepackage[active,tightpage]{preview}\PreviewEnvironment{tabular} % Load lua program, and define macros for accessing its functions ...

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}% ... 16 After getting these two answers I'd like to publish my solution also. After seeing jfbu's answer I was a bit intimidated and I went the luatex way. The code is probably not efficient, but it can produce an animated PDF – unfortunately this feature only works in Adobe Reader – or pages with the different evolution phases. Also this code only works with n×n ... 15 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}

14

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 ...

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

\documentclass{article} \usepackage{array} \newcount\tc \makeatletter \def\x@multispan#1{% \begingroup \@multicnt#1\relax \def\xtmp{}% \let\sp@n\relax \loop\ifnum\@multicnt>\@ne \xdef\xtmp{\xtmp\span\omit}\advance\@multicnt\m@ne\repeat \endgroup \xtmp} \protected\def\>#1{% \ifnum#1>\numexpr\tc+\@ne\relax ...

12

The mathtools provides a \vdotswithin command exactly for this situation: \documentclass{article} \usepackage{mathtools} \begin{document} \begin{align} 0 &= \text{some equation} \\ 0 &= \text{some other equation} \\ &\vdotswithin{=} \notag \\ 0 &= \text{last equation} \end{align} \end{document}

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} ...

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{array}{ccl} a + b + c & = & d \\ e + f & = & g \\ h & = & i \end{array}$$ ...

12

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 ...

12

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, ... 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 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 ... 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 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} ...

11

You can move the lines further apart by specifying arraystretch: \documentclass[a4paper,10pt]{article} \usepackage{arydshln} \setlength{\dashlinegap}{2pt} \begin{document} \[ \Gamma = \left({\renewcommand*{\arraystretch}{1.5} \begin{array}{c:c} \Gamma_{A} & \Gamma_{AB} \\ \hdashline (\Gamma_{AB})^\top & \Gamma_{B} ...

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} ...

10

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 ...

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 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 ...

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