删除表格行首的空格

删除表格行首的空格

在此处输入图片描述

有人能帮我删除表格中每行开头的空格吗?我试过所有方法:\arraystretch、\tablerowsep、\vspace{}。到目前为止,都没有用。以下是代码开头的一部分:

    \documentclass[8pt]{article}
%\usepackage[showframe]{geometry}
\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}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
\aboverulesep=0ex
\belowrulesep=0ex
%\renewcommand{\arraystretch}{5}
\newgeometry{margin=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=c]{90}{\makecell{Local Optimality 
Conditions}}} & \multicolumn{1}{p{0.7em}|}{\rotatebox[origin=c]{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=c]{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=c]{90}{\makecell{\ Global 
 Optimality Conditions}\ }} 
&
\multicolumn{1}{p{1.4em}|}{\rotatebox[origin=c]{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}

提前非常感谢您!

答案1

这不是答案。我所做的只是将您的代码片段转换为 MWE。有趣的是,问题并没有出现在那里。因此它一定来自您加载的某个包或代码中未显示的其他内容。

\documentclass{article}
\usepackage{geometry}
\usepackage{pdflscape,graphicx}
\usepackage{booktabs,array,makecell,multirow}
\usepackage{amsmath,amssymb}
\newcommand{\x}{\ensuremath{x}}
\newcommand{\h}{\ensuremath{h}}
\newcommand{\g}{\ensuremath{g}}
\begin{document}
\setlength{\aboverulesep}{0ex}
\setlength{\belowrulesep}{0ex}
%\renewcommand{\arraystretch}{5}
\newgeometry{margin=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=c]{90}{\makecell{Local Optimality Conditions}}} & \multicolumn{1}{p{0.7em}|}{\rotatebox[origin=c]{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.
\end{tabular}   
\end{table}
\end{landscape}
\end{document}

在此处输入图片描述

我猜,除非你非常幸运,否则唯一的办法就是提供完整的 MWE,而不仅仅是片段。

附录:我无法使用您的完整代码重现错误(在使用或在我的 TeXLive 2018 发行版上\end{document}编译时进行了修改。我也很惊讶它有效。这是我在其中实施@Mike 的建议以及另一项小更改的代码。xelatexlualatex\0

\documentclass[8pt]{article}
%\usepackage[showframe]{geometry}
\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=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}

在此处输入图片描述

所以从我的角度来看,这个问题无法重现。当你在你的机器上编译这段代码时,它真的会出现吗?

相关内容