2

This is what I tried, but failed to produce the desired result. Please Help! "LaTex Environment"

\documentclass[12pt, a4paper, oneside]{article}
\hyphenation{Fortran hy-phen-ation} % Specify custom hyphenation points in words with dashes where you would like hyphenation to occur, or alternatively, don't put any dashes in a word to stop hyphenation altogether
%\usepackage[T1]{fontenc} % output font encoding for international characters
\usepackage[english]{babel} % English language/hyphenation
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[utf8x]{inputenc}
%\usepackage{kpfonts}
%\DeclareUnicodeCharacter{211D} {\mathbb{R}}
%\DeclarationUnicodeCharacter{00A0} {}
%\DeclarationUnicodeCharacter{00A0} {~}
%\usepackage{fourier}
%\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage{xfrac}
\usepackage{sectsty} % Allows customizing section commands
%\allsectionsfont{\centering \normalfont\scshape} % Make all sections centered, the default font and small caps
\usepackage{multirow}
\usepackage{tikz}
\usepackage{booktabs}         %to use \toprule and \bottomrule without error message
\usepackage{pgfplots}         %to plot figure
\usepackage{threeparttable} 
\usepackage{booktabs}         %to use \toprule and \bottomrule without error message
\usepackage{pgfplots}   
\pgfplotsset{compat=1.5}
\usepackage{subfigure}        % to add subfigures
\usepackage{gensymb}
%\usepackage[none]{hyphenat}  %to prevent word breaking
\usepackage{siunitx}
\usepackage{caption}
\usepackage{booktabs} 
\newcommand*{\head}[1]{\textbf{#1}}%  to make heads of table in BOLD, it is used with booktabs package and \head
\usepackage{cleveref}
\usepackage{url} \makeatletter \g@addto@macro{\UrlBreaks}{\UrlOrds} \makeatother
\usepackage[justification=centering]{caption}
\PassOptionsToPackage{hyphens}{url}
%\usepackage{hyperref}
\usepackage{float}
%\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
%\usepackage[a4paper, portrait, margin=1in]{geometry}
\usepackage{adjustbox}
\usepackage{tabularx}
\usepackage{pgfplots, pgfplotstable}
\usepackage{booktabs,csvsimple}
\usepackage{pdflscape}
%% packages
%\input{settings/packages}
%% page setting
%\input{settings/pages}
%% own comments
%\usepackage[margin=1in]{geometry}
\usepackage{amsmath, amsfonts, amsthm} % needed for command eqref or Math packages
\usepackage{amssymb} % needed for math fonts
%\usepackage{hyperref}
\usepackage[
    colorlinks=true
   ,breaklinks
   %, ngerman
    ] {hyperref} % needed for creating hyperlinks in the docuent, the option colorlink=true gets rid of the awful boxes, breaklinks breaks lonk links (list of figures), and the ngerman sets everthing for german s default hyperlink languages.
%\usepackage[hyphenbreaks]{breakurl} 
\usepackage{xcolor}
\definecolor {c1}{rgb}{0,0, 1} % blue
\definecolor {c2}{rgb}{0.3,0.3, 0.9} % light blue
\definecolor {c3}{rgb}{0.3,0.3, 0.9} % red blue
\hypersetup{
   linkcolor={c1}, % internal links
    citecolor={c2}, % citations 
    urlcolor={c3} % external links/urls
}

%\usepackage[round, authoryear]{natbib} % needed for abbrvant bibliography style
%\usepackage[nottoc]{tocbibind} % needed for displaying bibliography and other in the table of contents
\usepackage{graphicx} % needed for\includegraphics
%\imp{graphicx}
\usepackage{longtable} % needed for long tables over pages
\usepackage{bigstrut} % needed for the  command \bigstrut
\usepackage{enumerate} % needed for some options in enumerate
%\usepackage{todonotes} % needed for todos
\usepackage{makeidx}  % needed for creating an index
\usepackage{xcolor}
\usepackage{blindtext} % needed for creating dummy text passage
\usepackage{lipsum}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage[nottoc, notlot, notlof]{tocbibind}
%% page settings%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[top=2cm, bottom=1.8cm, left=2.5cm, right=2.5cm]{geometry} % needed for page border stteings 
\parindent=0cm % for spece of first line of new text block
\sloppy % for writing with hypenless justification (tries to)
%\hyphenation {} % use hypenation of tolerance parameters, http://www.jr-x.de/publikationen/latex/tipps/zeilenumbruch_html
%\hyphenpenalty=10000
%\exhyphenpenalty=10000
%\usepackage{fancyhdr} % Custom headers and footers
%\usepackage{fourier} % Use the Adobe Utopia font for the document - comment this line to return to the LaTeX default
%\usepackage[english]{babel} % English language/hyphenation
%\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
%\usepackage{sectsty} % Allows customizing section commands
%\allsectionsfont{\centering \normalfont\scshape} % Make all sections centered, the default 

%\usepackage[round, authoryear]{natbib} % needed for cite and abbrvnat bibliograph style
\usepackage[nottoc]{tocbibind} % needed for displayng bibliography and other in the able of contents
%\usepackage{figures}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pagestyle{fancy}
\fancyhf{}
%\cfoot{\thepage}
\fancyhead {}
\fancyfoot{}
\fancyhead[L]{\slshape \MakeUppercase {Multidimensional Poverty Index (MPI) in Ethiopia}}
%\fancyhead[R]{\slshape WELDESLASSIE HAILAI}
\fancyfoot[C]{\thepage}
%\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

%\setlength{\parindent}{4em} %This is going to change the width of that indent
%\setlength{\parskip}{1em} % This is going to change the amount of spacing in between your paragraphes if you want that
\renewcommand{\baselinestretch}{1.5}%This affects the in spacing of my paragraphes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\graphicspath{ {images/} }
\begin{titlepage}
\begin{center}
\vspace*{1cm}
\pagestyle{empty}
\pagestyle{plain}
......
$$
\begin{array}{cc}
\text{Income} & \text{Years of Education} & \text{Improved Sanitation} & \text {Access to improved Electricity &\\
\begin{bmatrix}
900 & 10 & Yes & Yes\\
300 & 15 & No  & Yes \\
400 & 9  & No  & No \\
800 & 12 & Yes & Yes\\
1000& 13 & No  &  No
\end{bmatrix} &
\begin{small}
Person_1\\
Person_2\\
Person_3\\
Person_4\\
Person_5\\
\end{small}
\end{array}
 $$
......
\end {doocument}
  • 1
    this is hardly a "mimimal" example. and since there's no picture, it's somewhat necessary to guess what you actually want. however, from the title and the fact that you are using bmatrix, i think this might be helpful: \bordermatrix with brackets [ ] instead of parentheses – barbara beeton Feb 21 '17 at 16:24
  • @barbarabeeton: Thanks for your swift assistance. Sorry if I did not make myself clear. I am attempting to write a 5x4 Matrix and a text at the top of each column (such as income, yrs of education, electricity, sanitaiion) and in front of the rows (such as person 1, 2, 3, 4 and 5). Please assist me if I do not bother you as I am stuck in the middle of writing up my research. Thank you! – Hailai Weldeslassie Feb 21 '17 at 16:49
  • One solution is to force the columns inside the \multicolumn bmatrix to be the same size as those in the tabular. It would probably be easier to use \tikzmark and tikz to draw the brackets. See http://tex.stackexchange.com/questions/141885/how-to-align-the-columns-of-several-tables/142342?s=3|0.1323#142342 and http://tex.stackexchange.com/questions/291872/error-when-using-tikz-node-subnode – John Kormylo Feb 21 '17 at 18:40
  • @JohnKormylo: Thanks so much for your kind help. Can you please me in providing a practical solution to the problem I raised above? The reading references are great yet, I could not solve the problem after contacting them. – Hailai Weldeslassie Feb 22 '17 at 08:13
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – samcarter_is_at_topanswers.xyz Jul 21 '17 at 22:52

2 Answers2

3

Here is a solution with blkarray and makecell . The latter allows line breaks and a common formatting of cells introduced by the command \thead and \makecell. I took the opportunity to partly clean the preamble of the unnecessary packages and to remove double-loading of packages.

\documentclass[12pt, a4paper, oneside]{article}
\usepackage[english]{babel} % English language/hyphenation
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
\usepackage{xfrac}
\usepackage{multirow}
\usepackage{tikz}
\usepackage{pgfplots, pgfplotstable} %to plot figure
\usepackage{threeparttable}
\pgfplotsset{compat=1.5}
\usepackage{siunitx}
\usepackage{booktabs}
\newcommand*{\head}[1]{\textbf{#1}}% to make heads of table in BOLD, it is used with booktabs package and \head
\usepackage{url} \makeatletter \g@addto@macro{\UrlBreaks}{\UrlOrds} \makeatother
\usepackage[justification=centering]{caption}
\usepackage{float}
%\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
%\usepackage[a4paper, portrait, margin=1in]{geometry}
\usepackage{adjustbox}
\usepackage{tabularx, makecell}
\usepackage{booktabs,csvsimple}
\usepackage{pdflscape}
\usepackage{amsmath, amsfonts, amsthm} % needed for command eqref or Math packages
\usepackage{amssymb} % needed for math fonts
\usepackage[
    colorlinks=true
   ,breaklinks
   %, ngerman
    ] {hyperref} % needed for creating hyperlinks in the docuent, the option colorlink=true gets rid of the awful boxes, breaklinks breaks lonk links (list of figures), and the ngerman sets everthing for german s default hyperlink languages.
%\usepackage[hyphenbreaks]{breakurl}
\usepackage{cleveref}
\usepackage{xcolor}
\definecolor {c1}{rgb}{0,0, 1} % blue
\definecolor {c2}{rgb}{0.3,0.3, 0.9} % light blue
\definecolor {c3}{rgb}{0.3,0.3, 0.9} % red blue
\hypersetup{
   linkcolor={c1}, % internal links
    citecolor={c2}, % citations
    urlcolor={c3} % external links/urls
}
\usepackage{graphicx} % needed for\includegraphics
\usepackage{longtable} % needed for long tables over pages
\usepackage{bigstrut} % needed for the command \bigstrut
\usepackage{enumerate} % needed for some options in enumerate
\usepackage{blkarray}
\usepackage{lipsum}
\usepackage{setspace}
\usepackage{fancyhdr}
%% page settings%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[top=2cm, bottom=1.8cm, left=2.5cm, right=2.5cm]{geometry} % needed for page border stteings
\parindent=0cm % for spece of first line of new text block
\sloppy % for writing with hypenless justification (tries to)
\pagestyle{fancy}
\fancyhf{}
\fancyhead {}
\fancyfoot{}
\fancyhead[L]{\slshape \MakeUppercase {Multidimensional Poverty Index (MPI) in Ethiopia}}
%\fancyhead[R]{\slshape WELDESLASSIE HAILAI}
\fancyfoot[C]{\thepage}
%\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\baselinestretch}{1.5}%This affects the in spacing of my paragraphes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\theadset{\renewcommand{\arraystretch}{0.6}}
\renewcommand\theadfont{\small}
\renewcommand\theadalign{bc}

\begin{document}

\begin{center}
\begin{blockarray}{rcccc}
 & \thead{Income} & \thead{Years of \\Education} & \thead{Improved\\ Sanitation} & \thead{Access to\\ improved \\ Electricity}\\
\begin{block}{>{\small}r[cccc]}
Person\textsubscript{1} & 900 & 10 & Yes & Yes\\
Person\textsubscript{2}& 300 & 15 & No & Yes \\
Person\textsubscript{3} & 400 & 9 & No & No \\
Person\textsubscript{4} & 800 & 12 & Yes & Yes\\
Person\textsubscript{5} & 1000& 13 & No & No\\
\end{block}
\end{blockarray}
\end{center}

\end{document} 

enter image description here

Bernard
  • 271,350
  • Dear and esteemed Bernard, many thanks for your productive help. Yes! I was looking the same output. However, still, there is some problem. As per your kind your recommendation, I updated the use packages and I included the following: "\renewcommand\theadset{\renewcommand{\arraystretch}{0.6}} – Hailai Weldeslassie Feb 22 '17 at 08:10
  • Dear and esteemed @Bernard, many thanks for your productive help. Yes! I was looking the same output. However, still, there is some problem. As per your kind your recommendation, I updated the use packages and I included the following: "\renewcommand\theadset{\renewcommand{\arraystretch}{0.6}} – Hailai Weldeslassie – Hailai Weldeslassie Feb 22 '17 at 14:03
0

This solution overlays left and right brackets on the tabular using tikz. I removed all of your packages as they were irrelevant to the problem.

\documentclass{standalone}
\usepackage{tikz}

\newlength{\tempwidth}
\newlength{\tempheight}

\begin{document}
\begin{tabular}{rcccc}
 & Income & Years of Education & Improved Sanitation & Access to improved Electricity \\
Person\textsubscript{1} & \tikz[remember picture]{\node[inner sep=0pt](First){900};} & 10 & Yes & Yes\\
Person\textsubscript{2}& 300 & 15 & No & Yes \\
Person\textsubscript{3} & 400 & 9 & No & No \\
Person\textsubscript{4} & 800 & 12 & Yes & Yes\\
Person\textsubscript{5} & 1000& 13 & No & \tikz[remember picture]{\node[inner sep=0pt](Last){No};}\\
\end{tabular}
\begin{tikzpicture}[remember picture,overlay]
  \pgfextractx{\tempwidth}{\pgfpointdiff{\pgfpointanchor{First}{west}}{\pgfpointanchor{Last}{east}}}%
  \pgfextracty{\tempheight}{\pgfpointdiff{\pgfpointanchor{Last}{south}}{\pgfpointanchor{First}{north}}}%
  \path (First.north west) -- (Last.south east) node[midway] {$\displaystyle \left[ \rule[-0.5\tempheight]{0pt}{\tempheight}% vertical strut
    \rule{\tempwidth}{0pt} \right]$};% horizontal strut
\end{tikzpicture}
\end{document} 

demo


Personally, I don't get the reason for adding brackets. OTOH, it would be nice to have the numbers be right aligned and still be centered (more or less), hence the \makeboxs.

There are a number of ways to compute the widths for \makebox, including using a one column tabular {@{}r@{}}.

\documentclass{standalone}

\newlength{\firstcol}% width of first column (numbers only)
\newlength{\secondcol}% width of second column (numbers only)

\settowidth{\firstcol}{1000}% widest text
\settowidth{\secondcol}{15}

\begin{document}
\begin{tabular}{r|cccc}
 & Income & Years of Education & Improved Sanitation & Access to improved Electricity \\
\hline
Person\textsubscript{1} & \makebox[\firstcol][r]{900} & \makebox[\secondcol][r]{10} &Yes & Yes\\
Person\textsubscript{2}& \makebox[\firstcol][r]{300} & \makebox[\secondcol][r]{15} & No & Yes \\
Person\textsubscript{3} & \makebox[\firstcol][r]{400} & \makebox[\secondcol][r]{9} & No & No \\
Person\textsubscript{4} & \makebox[\firstcol][r]{800} & \makebox[\secondcol][r]{12} & Yes & Yes\\
Person\textsubscript{5} & \makebox[\firstcol][r]{1000} & \makebox[\secondcol][r]{13} & No & No \\
\end{tabular}
\end{document} 

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120