3

enter image description hereI combined 2 columns in the last row. How do I make the text in the form of bullets, start from the beginning of the row and not leave so much blank space? Also, how do I get rid of the space at the bottom of a row? Thanks in advance!

\documentclass[8pt]{article}
\usepackage{array}
\usepackage{pdflscape}
\usepackage{comment}
\usepackage{graphicx}
\usepackage{easytable}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{multirow,hhline,graphicx,array}
\usepackage[margin=0.5in]{geometry}

%\DeclareMathSizes{8}{16}{16}{8}

\newcommand{\x}{\mathbf{x}}
\newcommand{\g}{\mathbf{g}}
\newcommand{\h}{\mathbf{h}}
\newcommand{\0}{\mathbf{0}} %<- that's not a good idea
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
\aboverulesep=0ex
\belowrulesep=0ex
%\renewcommand{\arraystretch}{5}
\newgeometry{margin=0.1cm}
\begin{landscape}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
  \centering
  \caption{Add caption}
\begin{tabular}{|p{0.7em}| p{0.7em}|p{20em}|p{21em}|p{21em}|}
\cmidrule{3-5}    \multicolumn{1}{c}{} 
&       
& 
\makecell{\textbf{Unconstrained} \\ $\underset{\x\in\mathbb{R}^n}    
{\mathrm{minimize}}\ f(\x)$}
&
\makecell{\textbf{Constrained: Reduced Form} \\                     
$\underset{\x\in\mathbb{R}^n}{\mathrm{minimize}}\ f(\x)$ \\
$\mathrm{subject\ to\ } \h(\x)=\0 $} 
& 
\makecell{\textbf{Constrained: Lagrangian Form} \\ 
$\underset{\x\in\mathbb{R}^n}{\mathrm{minimize}}\ f(\x)$ \\
$\mathrm{subject\ to\ } \h(\x)=\0,\g(\x)\leq\0$ }
\\
\midrule
\multirow{2}{*}{\rotatebox[origin=r]{90}{\makecell{Local Optimality 
Conditions~~~~~~~~~~~~~~~~~~~~~~~~~~~~}}} & \multicolumn{1}{p{0.7em}|}            
{\rotatebox[origin=r]{90}{\ First Order Necessary~~~~~~\ }} 
& 
At a local minimizer, the gradient of the objective function must be zero 
\[
\nabla f(\x_\dagger)=\0
\]
& 
At a local minimizer, the reduced gradient must be zero if $\partial     
h/\partial s$ is invertible.
\[
\nabla_d f_R (x_{\dagger})=0
\]
\[
h(x_{\dagger})=0
\]
\[
\text{where } x= \begin{bmatrix}
d\\s
\end{bmatrix}
,\nabla_d f_R (x_{\dagger})=\frac{\partial f}{\partial d}-\frac{\partial f}    
{\partial s} \bigg( \frac{\partial h}{\partial s} \bigg )^{-1}\frac{\partial 
h}{\partial d}
\]
&  
At a local minimizer, the KKT conditions must be satisfied if the point is     
regular (i.e.: if the linear independence constraint qualification (LICQ) is 
satisfied: if $\nabla h_{\dagger}(x_{*})$ has independent rows).
\[
\nabla _x L(x_{\dagger})=0  
\]
\[
h(x_{\dagger})=0,g(x_{\dagger})≤0
\]
\[
\mu_{\dagger}^⊤ g(x_{\dagger})=0
\]
\[
\mu_{\dagger}≥0
\]
\[
\text{where } L(x_{\dagger})=f(x_{\dagger})+\lambda^⊤ h(x_{\dagger})+μ^⊤     
g(x_{\dagger})    
\]
\\
\cmidrule{2-5}    \multicolumn{1}{|c|}{} 
& 
\multicolumn{1}{p{0.7em}|}{\rotatebox[origin=r]{90}{\ Second Order     
Sufficiency~~~~~~~~\ }} 
&  
If the Hessian of the objective function is positive definite at a point 
where the gradient is zero, the point is a local minimum.
\[
\partial x^T\nabla^2f(x_{*})\partial x>0    
\]
\[
\forall \partial x \neq 0
\]
A Hessian matrix is positive definite if all of its eigenvalues are 
positive.
&    
If the reduced Hessian is positive definite at a point where the reduced 
gradient is zero, the point is a local minimum.
\[
\partial d^⊤ \nabla_d^2 f_R (x_{*})\partial d>0, \forall \partial d \neq 0
\]
\[
\text{where }\nabla_d^2 f_R (x_{*})=A \frac{\partial ^2 f}{\partial x^2}     
A^{T}+ \frac{\partial f}{\partial s} \frac{\partial ^2 s}{\partial d^2}
\]
\[
A=
\bigg[
I \hspace{2mm}\bigg({\frac{\partial s}{\partial d}\bigg)}^T
\bigg]
,  \frac{\partial^2 s}{\partial d^2} =-\bigg(\frac{\partial h}{\partial 
s}\bigg)^{-1} A \frac{\partial^2 h}{\partial x^2} A^{T}
\]
&  
If the Hessian of the Lagrangian is positive definite on the subspace      
tangent to the active constraints at a KKT point, the point is a local 
minimum.
\[
\partial x^T\nabla^2_x L(x_{*})\partial x>0    
    \]
    \[
    \forall \partial x \neq 0: \nabla_x h_{\dagger}(x_{*})\partial x = 0
    \]
    \[
    \text{where }h_{\dagger}(x_{*}) = [h(x_{*})^T, g_j(x_{*})\forall 
     j:\mu_j>0]^T
    \]
     A Hessian matrix is positive definite on the subspace tangent to the     
     active constraints if the last n-m leading principle minors of the 
     bordered Hessian $\begin{bmatrix}
 0 & \nabla h\\ \nabla h^T & \nabla^2_x L
 \end{bmatrix}$have sign $(-1)^m$, where m is the number of active 
 constraints.
\\
\midrule
\multicolumn{1}{|p{1.4em}|}{\rotatebox[origin=r]{90}{\makecell{\ Global Optimality Conditions~~~~~~~}\ }} 
&
\multicolumn{1}{p{1.4em}|}{\rotatebox[origin=r]{90}{\makecell{\         
Convexity~~~~~~~~~~~~~~~~~~}\ 
}} 
&       
\begin{itemize}
\item For convex functions, if a point is a local minimum it is also the 
global minimum and a local minimizer is also a global minimizer (not 
necessarily the only one).
\item If the objective function is nonconvex, it may or may not have     
multiple local minima.
\item A convex function* is a function whose Hessian is positive 
semidefinite for all x.
\item A Hessian matrix is positive semidefinite if all of its eigenvalues 
are nonnegative.
\end{itemize}
& 
 \multicolumn{1}{c}{}
 &
\begin{itemize}
\item A convex optimization problem is a problem in negative null form where     
f(x) and g(x) are each convex functions and h(x) are affine functions.
\item For convex optimization problems, a local minimum is also the global     
minimum, and a local minimizer is also a global minimizer (not necessarily the only one).
\item A nonconvex optimization problem may or may not have multiple 
local minima and/or disconnected feasible regions.
 \end{itemize} 
 \\
 \bottomrule
 \end{tabular}%
  \label{tab:addlabel}%
\end{table}%
\end{landscape}
\restoregeometry
\end{document}
Cat
  • 77

2 Answers2

2

Here is an improvement: some code simplification exploiting the possibilities of makecell, enumitem and loading tabularx:

\documentclass[8pt]{extarticle}
\usepackage{array}
\usepackage{pdflscape}
\usepackage{comment}
\usepackage{graphicx}
\usepackage{easytable}
\usepackage{enumitem}
\usepackage{amssymb}
\usepackage{mathtools, nccmath, esdiff}
\usepackage{rotating}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize\bfseries}
\usepackage{booktabs}
\usepackage{multirow,hhline,graphicx,array, caption, tabularx}
\usepackage[margin=0.5in]{geometry}

\newcommand{\x}{\mathbf{x}}
\newcommand{\g}{\mathbf{g}}
\newcommand{\h}{\mathbf{h}}
\newcommand{\0}{\mathbf{0}} %<- that's not a good idea
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\newlength{\TXcolwd}

\begin{document}
\aboverulesep=0ex
\belowrulesep=0ex
\renewcommand{\theadalign}{tc}
\newgeometry{margin=0.1cm}
\begin{landscape}
\null\vfill
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
\setlist[itemize, 1]{wide=0pt, leftmargin=*, before=\compress, after=\vspace*{\dimexpr\topsep-\baselineskip}}
\setlength{\extrarowheight}{4pt}
  \centering
  \caption{Add caption}
\begin{tabularx}{\linewidth}{|c|c|X|X|X|}% }{|p{0.7em}|p{0.4em}|X|X|X|}% p{0.7em}
\cmidrule{3-5} \multicolumn{1}{c}{}
& & \thead{Unconstrained \\[1ex] $\underset{\x \in \mathbb{R}^n}
{\mathrm{minimize}}\ f(\x)$}
&
\thead{Constrained: Reduced Form \\
$\begin{array}{l}\underset{\x \in \mathbb{R}^n}{\mathrm{minimize}}\ f(\x) \\
\mathrm{subject\ to\enspace} \h(\x)=\0
\end{array} $}
&
\thead{Constrained: Lagrangian Form \\
$\begin{array}{l}\underset{\x \in \mathbb{R}^n}{\mathrm{minimize}}\ f(\x) \\
\mathrm{subject\ to\ } \h(\x)=\0,\g(\x)\leq\0
\end{array} $ } \\
\midrule
\multirowcell{20}{\rotatebox{90}{Local Optimality Conditions}}%
& 
\multirowcell{9}{\rotatebox{90}{First Order Necessary}}
&
 At a local minimizer, the gradient of the objective function must be zero
\[ \nabla f(\x_\dagger)=\0 \]
& 
At a local minimizer, the reduced gradient must be zero if $\partial h/\partial s$ is invertible. \useshortskip
\begin{gather*}
\nabla_d f_R (x_{\dagger})=0 \\
h(x_{\dagger})=0 \\
\text{where } x= \begin{bmatrix}
d\\s
\end{bmatrix},\:\nabla_d f_R (x_{\dagger})=\frac{\partial f}{\partial d}-\frac{\partial f}
{\partial s} \biggl( \diffp{h}{s} \biggr )^{\mkern-6mu-1}\diffp{h}{d}
\end{gather*}
& 
At a local minimizer, the KKT conditions must be satisfied if the point is regular (i.e.: if the linear independence constraint qualification (LICQ) is satisfied: if $ \nabla h_{\dagger}(x_{*})$ has independent rows).\useshortskip
\begin{gather*}
\nabla _x L(x_{\dagger})=0 \\
h(x_{\dagger})=0,g(x_{\dagger}) \le 0 \\
\mu_{\dagger}^T g(x_{\dagger})=0 \\
\mu_{\dagger} \ge 0 \\
\text{where } L(x_{\dagger})=f(x_{\dagger})+\lambda^T h(x_{\dagger})+\mu ^T
g(x_{\dagger})
\end{gather*}
\vspace*{\dimexpr 1ex-\baselineskip} \\
\cmidrule{2-5}%
& 
\multirowcell{11}{\rotatebox{90}{Second Order Sufficiency}} %
&
 If the Hessian of the objective function is positive definite at a point where the gradient is zero, the point is a local minimum.
 \begin{gather*}
\partial x^T\nabla^2f(x_{*})\partial x>0 \\
\forall \partial x \neq 0
\end{gather*}
A Hessian matrix is positive definite if all of its eigenvalues are positive.
&
 If the reduced Hessian is positive definite at a point where the reduced gradient is zero, the point is a local minimum.
\begin{gather*}
\partial d^T \nabla_d^2 f_R (x_{*})\partial d>0, \forall \partial d \neq 0 \\
\text{where }\nabla_d^2 f_R (x_{*})=A \frac{\partial ^2 f}{\partial x^2}
A^{T}+ \diffp{f}{s} \diffp[2]{s}{d} \\
A= \biggl[
I \hspace{2mm}\biggl({\diffp{s}{d}\biggr)}^T
\biggr],
\frac{\partial^2 s}{\partial d^2} =-\biggl(\diffp{h}{s}\biggr)^{\mkern-6mu -1} A\, \diffp[2]{h}{x} A^{T}
 \end{gather*}
& 
If the Hessian of the Lagrangian is positive definite on the subspace tangent to the active constraints at a KKT point, the point is a local minimum.
\begin{gather*}
\partial x^T\nabla^2_x L(x_{*})\partial x>0 \\
 \forall \partial x \neq 0: \nabla_x h_{\dagger}(x_{*})\partial x = 0 \\
 \text{where }h_{\dagger}(x_{*}) = [h(x_{*})^T, g_j(x_{*})\forall
 j:\mu_j>0]^T
 \end{gather*}
 A Hessian matrix is positive definite on the subspace tangent to the active constraints if the last $ n $-$ m $ leading principal minors of the bordered Hessian %
 $\begin{bmatrix}
 0 & \nabla h\\ \nabla h^T & \nabla^2_x L
 \end{bmatrix}$have sign $(-1)^m$, where $ m $ is the number of active
 constraints. \smallskip
\\
\midrule
\multirowcell{9}{\rotatebox{90}{Global Optimality Conditions}}
&
\multirowcell{9}{\rotatebox{90}{Convexity}}
& \begin{itemize}
\item For convex functions, if a point is a local minimum it is also the global minimum and a local minimizer is also a global minimizer (not necessarily the only one).
\item If the objective function is nonconvex, it may or may not have multiple local minima.
\item A convex function* is a function whose Hessian is positive semidefinite for all x.
\item A Hessian matrix is positive semidefinite if all of its eigenvalues are nonnegative.
\end{itemize}
& 
\multicolumn{2}{p{57em}|}{%
\begin{itemize}
\item A convex optimization problem is a problem in negative null form where f(x) and g(x) are each convex functions and h(x) are affine functions.
\item For convex optimization problems, a local minimum is also the global minimum, and a local minimizer is also a global minimizer (not necessarily the only one).
\item A nonconvex optimization problem may or may not have multiple local minima and/or disconnected feasible regions.
 \end{itemize}} \\
 \bottomrule
 \end{tabularx}%
  \label{tab:addlabel}%
\end{table}%
\vfill
\end{landscape}
\restoregeometry

\end{document}

enter image description here

Bernard
  • 271,350
  • Thank you so so much! Looks like you fixed everything! I will go through what you did and try to understand, and get back to you if I need to ask something. – Cat May 22 '18 at 15:25
  • You're welcome! Feel free to ask. – Bernard May 22 '18 at 15:27
  • So I used your code for another similar table that I am making. But this time it rotates the table 90 degrees and leaves a page blank in the beginning. Should I start a new thread for this? Also how do you adjust the size of the columns? What if I don;t want all 3 columns to be the same size? Thank you very much in advance! – Cat May 22 '18 at 17:33
  • 1
    Probably you should post a new thread with a minimal example. Note the values for multirow were found by trial and error, and have to be adjusted for another table. The size of the last three columns should be all equal since they're calculatedx by tabularx so the table fits the text width (there might be an artefact due to the final multicolumn{2}{p{somewidth}}. – Bernard May 22 '18 at 18:31
  • I have copied the link for my new question on rotating a table: https://tex.stackexchange.com/questions/432893/table-getting-rotated-by-90-degrees – Cat May 22 '18 at 19:34
  • In your table, how can I center the text? The \centering command does not work for the 3 boxes in the last column. It works everywhere else. Thanks! – Cat May 23 '18 at 16:17
  • 1
    @Cat: Replace the tabulatx preamble with {|c|c|X|X|>\centering \arraybackslash}X|} (tested). However, I don't think it looks very nice. – Bernard May 23 '18 at 16:23
  • Thank you very much again! That works. I could also make it work by adding & at the end of the column. But what if I wanted to center all the boxes instead of just the last column? Should I copy what you did for all the other columns in the preamble? Is there a more composite way of doing this. Thanks! – Cat May 23 '18 at 16:36
  • Yes you add the same modification for you other columns, or simpler: you define a new column type: \newcolumntype{Y} {>{\centering\arraybackslash}X}. B.t.w. I 've taken a look at your other table, but I have problems compiling it. I'll post an answer as soon as I can. – Bernard May 23 '18 at 16:52
  • All my problems are fixed. (Except for wanting to vary the size of the columns, which you said is not possible for tabularx). I incorporated all the suggestions posted by people in that other thread for the other table. Thank you very much nevertheless for offering your help. I had been stuck on these problems for a long time and I am glad there is an online community that is so willing to help. :) Are you a latex expert? – Cat May 23 '18 at 17:11
  • I'm not really an expert, in the sense that I do not really master the internals, but I know well a number of packages that I've been using for more than 20 years. You can vary the relative widths of X columns, using in the preamble >{\hsize= some coefficient\hsize}X. The condition is that the sum of the coefficients for the X columns in a tabularx be equal to the total number of X columns. For instance, with X columns, the coefficients 0.5 and 1.5 will yield two X columns, of which one is thrice as wide as the other. – Bernard May 23 '18 at 17:25
1

I think you have to use the \multicolumn command differently:

\multicolumn{2}{p{42em}|}{
\begin{itemize}
\item A convex optimization problem is a problem in negative null form
where f(x) and g(x) are each convex functions and h(x) are affine 
functions.
\item For convex optimization problems, a local minimum is also the global
minimum, and a local minimizer is also a global minimizer (not necessarily 
the only one).
\item A nonconvex optimization problem may or may not have multiple
local minima and/or disconnected feasible regions.
\end{itemize}}

See the documentation or How to merge columns in a table? when in doubt.

As to the vertical alignment, the column type m should do the trick: p,m and b columns in tables

  • Yes that works! Thank you so much for your help! And thank you also for the links! – Cat May 22 '18 at 15:26