2

I have a 3 column table and in the third column I am representing a $20\times 1$ vector. I would like to put square brackets on each side of this vector.

\documentclass[a4paper,12pt,times,numbered,print,index]{Classes/PhDThesisPSnPDF}

\RequirePackage[left=37mm,right=30mm,top=35mm,bottom=30mm]{geometry}
\RequirePackage{libertine} 
\RequirePackage[small,bf]{caption}
\RequirePackage[labelsep=space,tableposition=top]{caption} 
\usepackage{subfig}  
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{braket}
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx

\begin{document}

\begin{table}[ph]
  \centering
  \begin{tabular}{| >{$}c<{$} | >{$}c<{$} | >{$}c<{$} |}
    \hline
    \text{Position} & \text{State} & \text{P} \\
    \hline
    \multirow{4}{*}{-2} 
    & \ket{\leftarrow, 0}   & 0 \\
    & \ket{\leftarrow, 1}   & 0 \\
    & \ket{\rightarrow, 0}  & 0 \\
    & \ket{\rightarrow, 1}  & 0 \\
    \hhline{--~}
    \multirow{4}{*}{-1} 
    & \ket{\leftarrow, 0}   & 0 \\
    & \ket{\leftarrow, 1}   & 0 \\
    & \ket{\rightarrow, 0}  & 0 \\
    & \ket{\rightarrow, 1}  & 0 \\
    \hhline{--~}
    \multirow{4}{*}{0} 
    & \ket{\leftarrow, 0}   & 1 \\
    & \ket{\leftarrow, 1}   & 0 \\
    & \ket{\rightarrow, 0}  & 0 \\
    & \ket{\rightarrow, 1}  & 0 \\
    \hhline{--~}
    \multirow{4}{*}{1} 
    & \ket{\leftarrow, 0}   & 0 \\
    & \ket{\leftarrow, 1}   & 0 \\
    & \ket{\rightarrow, 0}  & 0 \\
    & \ket{\rightarrow, 1}  & 0 \\
    \hhline{--~}
    \multirow{4}{*}{2} 
    & \ket{\leftarrow, 0}   & 0 \\
    & \ket{\leftarrow, 1}   & 0 \\
    & \ket{\rightarrow, 0}  & 0 \\
    & \ket{\rightarrow, 1}  & 0 \\
    \hline    
  \end{tabular}
  \caption{Interpretation of the particle matrix for a $1$-step memory walk. Observe that for each position we are able
  to represent the p}
  \label{T:peak}
\end{table}
\end{document}

Does any one know how to place square brackets on either side of the vector P?

1
  • Square brackets would be great.
    – sonicboom
    Apr 5, 2014 at 15:50

1 Answer 1

2

Your objective may be achieved by (a) breaking up the tabular environment into two separate array environments that are placed side by side and (b) placing the column vector that's surrounded by square brackets in the second array, which consists of a single column. (Why array instead of tabular? Because the material being typeset, other than the header row, is all math-related; using an array seems more natural.) The second array environment contains (i) a header row and (ii) a nested array environment containing the 20-element vector, surrounded by square brackets. Note the use of [0.4pt] of extra spacing after every fourth row of the column vector: This allows for the width of \hline, which equals (you guessed it) 0.4pt.

I've set the spacing of the square brackets around the column vector deliberately rather tight. If you'd like a bit more space, you could replace the instruction \begin{array}{@{}c@{}} with, say, \begin{array}{@{\hspace{1pt}}c@{\hspace{1pt}}}.

Finally, since I don't have access to the PhDThesisPSnPDF document class, I substituted in the article class.

enter image description here

\documentclass[a4paper,12pt,times,numbered,print,index]{article}   
\RequirePackage[left=37mm,right=30mm,top=35mm,bottom=30mm]{geometry}
\RequirePackage{libertine} 
\RequirePackage[small,bf,labelsep=space,
    tableposition=top]{caption} 
\usepackage{multirow}  
\usepackage{subfig,amsfonts,amsmath,amssymb,braket}
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx

\begin{document}
\begin{table}
  \centering
  $  % start math mode
  \begin{array}{| c | c |}
  \hline
    \text{Position} & \text{State}  \\
    \hline
    \multirow{4}{*}{$-$2} 
    & \ket{\leftarrow, 0}   \\
    & \ket{\leftarrow, 1}   \\
    & \ket{\rightarrow, 0}  \\
    & \ket{\rightarrow, 1}  \\
    \hline
    \multirow{4}{*}{$-$1} 
    & \ket{\leftarrow, 0}   \\
    & \ket{\leftarrow, 1}   \\
    & \ket{\rightarrow, 0}  \\
    & \ket{\rightarrow, 1}  \\
    \hline
    \multirow{4}{*}{0} 
    & \ket{\leftarrow, 0}   \\
    & \ket{\leftarrow, 1}   \\
    & \ket{\rightarrow, 0}  \\
    & \ket{\rightarrow, 1}  \\
    \hline
    \multirow{4}{*}{1} 
    & \ket{\leftarrow, 0}   \\
    & \ket{\leftarrow, 1}   \\
    & \ket{\rightarrow, 0}  \\
    & \ket{\rightarrow, 1}  \\
    \hline
    \multirow{4}{*}{2} 
    & \ket{\leftarrow, 0}   \\
    & \ket{\leftarrow, 1}   \\
    & \ket{\rightarrow, 0}  \\
    & \ket{\rightarrow, 1}  \\
  \hline    
  \end{array}% no separation between the two arrays
  \begin{array}{c|}
  \hline
  \text{P}\\ 
  \hline
    \left[ \begin{array}{@{}c@{}}
    0 \\ 0 \\ 0 \\ 0 \\[0.4pt]  
    0 \\ 0 \\ 0 \\ 0 \\[0.4pt] 
    1 \\ 0 \\ 0 \\ 0 \\[0.4pt]   
    0 \\ 0 \\ 0 \\ 0 \\[0.4pt]   
    0 \\ 0 \\ 0 \\ 0 \\  
    \end{array}\right] \\ 
  \hline
  \end{array} 
  $  % end of math mode
  \caption{Interpretation of the particle matrix for a $1$-step memory walk. 
      Observe that for each position we are able to represent the p}
  \label{T:peak}
\end{table}
\end{document}
1
  • @sonicboom - Thanks! By the way, I didn't mention this explicitly in the main part of the answer, but you may want to get rid of all vertical lines that separate the columns. Why? Because their thickness (0.4pt) is noticeably different from that of the square brackets that surround the vector in the third column. You can get rid of the vertical lines by defining the two "outer" arrays as \begin{array}{cc} and \begin{array}{c}, resp.
    – Mico
    Apr 5, 2014 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .