Math & ScienceProblem with delimiters of a matrix

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

Problem with delimiters of a matrix

Post by NELLLY »

Hi I have the following

Code: Select all

\documentclass[12pt]{article}
\setlength{\topmargin} {-3cm} \setlength{\headheight} {1.5cm}
\setlength{\headsep} {1cm} \setlength{\oddsidemargin} {1cm}
\setlength{\textheight} {21cm} \setlength{\textwidth} {15cm}
\usepackage{natbib}
\linespread{2}
 \bibpunct[, ]{(}{)}{,}{a}{}{,}%
 \def\bibfont{\small}%
 \def\bibsep{\smallskipamount}%
 \def\bibhang{24pt}%
 \def\newblock{\ }%
 \def\BIBand{and}%

\hyphenpenalty 10000
\date{}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{rotating,caption2}
\usepackage{graphicx, float}
\usepackage[bf]{titlesec}
\usepackage{titletoc}
\makeatletter \if@titlepage
  \renewenvironment{abstract}{%
      \titlepage
      \null\vfil
      \@beginparpenalty\@lowpenalty
      \begin{center}%
        \bfseries \abstractname
        \@endparpenalty\@M
      \end{center}}%
     {\par\vfil\null\endtitlepage}
\else
  \renewenvironment{abstract}{%
      \if@twocolumn
        \section*{\abstractname}%
      \else
        \small
        \list{}{%
          \settowidth{\labelwidth}{\textbf{\abstractname:}}
          \setlength{\leftmargin}{0pt}
          \setlength{\itemindent}{\labelwidth}
          \addtolength{\itemindent}{\labelsep}
        }
        \item[\textbf{\abstractname:}]

      \fi}
      {\if@twocolumn\else\endlist\fi}
\fi \makeatother

%\begin{document}
%%%% debut macro %%%%
\makeatletter
\renewcommand{\fnum@figure}{\textbf{\textit{\figurename~\thefigure}}}
\renewcommand{\fnum@table}{\textbf{\tablename~\thetable}}
\renewcommand{\captionlabeldelim}{.}
\makeatother
\renewcommand{\refname}{REFERENCES}
\renewcommand*\abstractname{Abstract\hfill}

%%%% fin macro %%%%

%\titleformat*{\section}{\scshape}
\titleformat{\section}{\normalfont\bfseries}{\thesection.}{0.2em}{\uppercase}
%\titlelabel{\thesection.\quad}
\makeatletter
\newif\if@borderstar
   \def\bordermatrix{\@ifnextchar*{%
       \@borderstartrue\@bordermatrix@i}{\@borderstarfalse\@bordermatrix@i*}%
   }
   \def\@bordermatrix@i*{\@ifnextchar[{\@bordermatrix@ii}{\@bordermatrix@ii[()]}}
   \def\@bordermatrix@ii[#1]#2{%
   \begingroup
     \m@th\@tempdima8.75\p@\setbox\z@\vbox{%
       \def\cr{\crcr\noalign{\kern 2\p@\global\let\cr\endline }}%
       \ialign {$##$\hfil\kern 2\p@\kern\@tempdima & \thinspace %
       \hfil $##$\hfil && \quad\hfil $##$\hfil\crcr\omit\strut %
       \hfil\crcr\noalign{\kern -\baselineskip}#2\crcr\omit %
       \strut\cr}}%
     \setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
     \setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
     \setbox\tw@\hbox{%
       $\kern\wd\@ne\kern -\@tempdima\left\@firstoftwo#1%
         \if@borderstar\kern2pt\else\kern -\wd\@ne\fi%
       \global\setbox\@ne\vbox{\box\@ne\if@borderstar\else\kern 2\p@\fi}%
       \vcenter{\if@borderstar\else\kern -\ht\@ne\fi%
         \unvbox\z@\kern-\if@borderstar2\fi\baselineskip}%
         \if@borderstar\kern-2\@tempdima\kern2\p@\else\,\fi\right\@secondoftwo#1 $%
     }\null \;\vbox{\kern\ht\@ne\box\tw@}%
   \endgroup
   }
\makeatother
\begin{document}
\[P_0^{(1)}=\bordermatrix[{[]}]{
& 1 & 2\cr 1 & a& 1-a\cr 2&b&1-b }\]
\end{document}
The problem is that there is a space between the start of the delimiters [ ] and the first line of the matrix.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Problem with delimiters of a matrix

Post by gmedina »

Hi,

I don't see any odd space; I atach the pdf obtained with your code. Can you please explain which space are you referring to?
Attachments
test.pdf
(40.74 KiB) Downloaded 227 times
1,1,2,3,5,8,13,21,34,55,89,144,233,...
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

Problem with delimiters of a matrix

Post by NELLLY »

Hi
If I use the following preambule instead of the first one

Code: Select all


\documentclass[12pt]{article}
\setlength{\topmargin} {-3cm} \setlength{\headheight} {1.5cm}
\setlength{\headsep} {1cm} \setlength{\oddsidemargin} {1cm}
\setlength{\textheight} {21cm} \setlength{\textwidth} {15cm}
\usepackage{natbib}

\hyphenpenalty 10000
\date{}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{rotating,caption2}
\usepackage{graphicx, float}
\usepackage[bf]{titlesec}
\usepackage{titletoc}

\makeatletter
\newif\if@borderstar
   \def\bordermatrix{\@ifnextchar*{%
       \@borderstartrue\@bordermatrix@i}{\@borderstarfalse\@bordermatrix@i*}%
   }
   \def\@bordermatrix@i*{\@ifnextchar[{\@bordermatrix@ii}{\@bordermatrix@ii[()]}}
   \def\@bordermatrix@ii[#1]#2{%
   \begingroup
     \m@th\@tempdima8.75\p@\setbox\z@\vbox{%
       \def\cr{\crcr\noalign{\kern 2\p@\global\let\cr\endline }}%
       \ialign {$##$\hfil\kern 2\p@\kern\@tempdima & \thinspace %
       \hfil $##$\hfil && \quad\hfil $##$\hfil\crcr\omit\strut %
       \hfil\crcr\noalign{\kern -\baselineskip}#2\crcr\omit %
       \strut\cr}}%
     \setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
     \setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
     \setbox\tw@\hbox{%
       $\kern\wd\@ne\kern -\@tempdima\left\@firstoftwo#1%
         \if@borderstar\kern2pt\else\kern -\wd\@ne\fi%
       \global\setbox\@ne\vbox{\box\@ne\if@borderstar\else\kern 2\p@\fi}%
       \vcenter{\if@borderstar\else\kern -\ht\@ne\fi%
         \unvbox\z@\kern-\if@borderstar2\fi\baselineskip}%
         \if@borderstar\kern-2\@tempdima\kern2\p@\else\,\fi\right\@secondoftwo#1 $%
     }\null \;\vbox{\kern\ht\@ne\box\tw@}%
   \endgroup
   }
\makeatother
\begin{document}
\[P_0^{(1)}=\bordermatrix[{[]}]{
& 1 & 2\cr 1 & a& 1-a\cr 2&b&1-b }\]
\end{document}
I get the attached file. I wonder why I didn't get the same output.
Attachments
essaiamsmath.pdf
(13.23 KiB) Downloaded 235 times
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

Problem with delimiters of a matrix

Post by NELLLY »

Hi
When I use in the preambule

Code: Select all

\linespread{1}
Instead of

Code: Select all

\linespread{2}
there is no problem with the delimiters. But I should use

Code: Select all

\linespread{2}
Is there a solution?
Post Reply