Estoy escribiendo mis fórmulas matemáticas y restricciones con Overleaf. Este es mi código y también les muestro el resultado que obtuve (ver imagen). Como puedes ver, las fórmulas no están bien alineadas. Me gustaría mejorar el diseño alineando todas las fórmulas y etiquetándolas (con números, como se muestra en la imagen). ¡Sería de gran ayuda si alguien pudiera ayudarme con esto!
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[super]{natbib}
\usepackage{comment}
\usepackage{graphicx}
\usepackage{float}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{caption}
\usepackage{adjustbox}
\usepackage{lipsum}
\usepackage{lscape}
\usepackage{multicol}
\usepackage{longtable}
\captionsetup[figure]{font=small,labelfont=bf}
\captionsetup[table]{font=small,labelfont=bf}
\usepackage[justification=centering]{caption}
\usepackage{eurosym}
\usepackage{mhchem}
\usepackage{relsize}
\usepackage[table, dvipsnames]{xcolor}
\renewcommand*\descriptionlabel[1]{\hspace\leftmargin$#1$}
\usepackage[hidelinks]{hyperref}
\usepackage{enumitem}
\usepackage{glossaries}
\makeglossaries
\newcommand{\mathgl}[2]{
\newglossaryentry{#1}{name={#1},description={#2}}
\begin{description}[labelwidth=2cm]
\item[\gls{#1}]#2
\end{description}
}
\makeatletter
\newcommand*{\rom}[1]{\expandafter\@slowromancap\romannumeral #1@}
\makeatother
\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
\let\endchangemargin=\endlist
\begin{document}
\subsection{Stating the objective function}
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
\begin{align}
\min \quad BFC \cdot \bigg(\mathlarger{\mathlarger{\sum}}_{i\in I}Fc_i \cdot u_i\bigg)
+
BEC \cdot \bigg(\mathlarger{\mathlarger{\sum}}_{i\in I}\mathlarger{\mathlarger{\sum}}_{j \in J}\mathlarger{\mathlarger{\sum}}_{p \in P}x_i_j_p\cdot Ec_i_j_p_y\bigg)
+
BTC \cdot \bigg(\mathlarger{\mathlarger{\sum}}_{i\in I}\mathlarger{\mathlarger{\sum}}_{j \in J}\mathlarger{\mathlarger{\sum}}_{p \in P}x_i_j_p\cdot Tc_i_j_p\bigg)
+
BWC \cdot \bigg(\mathlarger{\mathlarger{\sum}}_{i\in I}\mathlarger{\mathlarger{\sum}}_{j \in J}\mathlarger{\mathlarger{\sum}}_{p \in P}x_i_j_p\cdot Wc_i_j_p\bigg)
+
BZC \cdot \bigg(\mathlarger{\mathlarger{\sum}}_{i\in I}\mathlarger{\mathlarger{\sum}}_{j \in J}\mathlarger{\mathlarger{\sum}}_{p \in P}x_i_j_p\cdot Z_i_j_p\bigg)\cdot Zc
\label{1}
\end{align}
\subsection{Stating the constraints}
The first constraint ensures that the demand of each customer is satisfied:
\begin{align}
\mathlarger{\sum}_{i\in I}x_i_j_p = D_j_p_y, \quad && \forall j \in J, p\in P, y \in Y\label{2}
\end{align}
\noindent The second formula makes sure that the maximum capacity of each supplier facility is not exceeded:
\begin{align}
\mathlarger{\sum}_{j\in J}\mathlarger{\sum}_{p\in P}x_i_j_p \leq u_i, \quad && \forall i \in I \label{3}
\end{align}
\noindent Contracts with specific supplier facilities may agree on minimum allocation volumes. This is ensured by the following formula:
\begin{align}
\mathlarger{\sum}_{j\in J}\mathlarger{\sum}_{p\in P}x_i_j_p \geq V_i, \quad && \forall i \in I \label{3}
\end{align}
\noindent Specific breweries desire to be supplied by at least two suppliers for some specific type of product code. This is ensured by the following two formulas:
\begin{align}
\mathlarger{\sum}_{i\in I}J_i_j_p \geq 2, \quad && \forall j \in J, p\in P \label{4}\\
x_i_j_p \geq b_i_j_p M_j_p
\end{align}
\noindentSpecific OpCos desire to be supplied by at least two suppliers for some specific type of product code. This is ensured by the following two formulas:
\begin{align}
\mathlarger{\sum}_{i\in I}F_i_o_p\geq 2,\quad && \forall o \in O, p\in P \label{5}\\
\mathlarger{\sum}_{i\subset I}x_i_j_p \geq F_i_o_pG_o_p,\quad && \forall i \in I, o\in O, p\in P \label{5}
\end{align}
Respuesta1
Una solución sencilla utiliza un único align
entorno y el \intertext
comando.
Simplifiqué el preámbulo de lo necesario para que el código funcione. Además, no creo que realmente necesites usar un double \mathlarger
, lo que hace que el número de la ecuación se coloque debajo de la ecuación, incluso cuando se usamultlined
Por cierto, no tienes que cargar amsfonts
cuando cargas amssymb
: este último lo hace por ti. Tenga en cuenta que hyperref
debe cargarse como último paquete, con muy pocas excepciones.
\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{relsize}
\usepackage[hidelinks]{hyperref}
\begin{document}
\setcounter{section}{4}
\setcounter{subsection}{5}
\subsection{Stating the objective function}
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
\begin{equation}
\begin{multlined}
\min \quad BFC \cdot \bigg(\mathlarger{\sum}_{i\in I}Fc_i \cdot u_i\bigg)
+
BEC \cdot \bigg(\mathop{\mathlarger{\sum}_{i\in I}\mathlarger{\sum}_{j \in J}\mathlarger{\sum}_{p \in P}x_{i j p}}\cdot Ec_{ijpy}\bigg) +{}
\\
BTC \cdot \bigg(\mathlarger{\sum}_{i\in I}\mathlarger{\sum}_{j \in J}\mathlarger{\sum}_{p \in P}x_{ijp}\cdot Tc_{ijp}\bigg)
+
BWC \cdot \bigg(\mathlarger{\sum}_{i\in I}\mathlarger{\sum}_{j \in J}\mathlarger{\sum}_{p \in P}x_{ijp}\cdot Wc_{ijp}\bigg)
\\
+ BZC \cdot \bigg(\mathlarger{\sum}_{i\in I}\mathlarger{\sum}_{j \in J}\mathlarger{\sum}_{p \in P}x_{ijp}\cdot Z_{ijp}\bigg)\cdot Zc
\end{multlined}
\label{1}
\end{equation}
\subsection{Stating the constraints}
The first constraint ensures that the demand of each customer is satisfied:
\begin{align}
\mathlarger{\sum}_{i\in I}&x_{ijp} = D_{jpy}, \quad && \forall j \in J, p\in P, y \in Y\label{2} \\
\intertext{The second formula makes sure that the maximum capacity of each supplier facility is not exceeded:}
\mathlarger{\sum}_{j\in J}\mathlarger{\sum}_{p\in P} &x_{ijp} \leq u_i, \quad && \forall i \in I \label{3}
\intertext{Contracts with specific supplier facilities may agree on minimum allocation volumes. This is ensured by the following formula:}
\mathlarger{\sum}_{j\in J} \mathlarger{\sum}_{p\in P} &x_{ijp}\geq V_i, \quad && \forall i \in I \label{3} \\
\intertext{Specific breweries desire to be supplied by at least two suppliers for some specific type of product code. This is ensured by the following two formulas:}
\mathlarger{\sum}_{i\in I}&J_{ijp} \geq 2, \quad && \forall j \in J, p\in P \label{4}\\
&x_{ijp} \geq b_{ijp} M_{jp}\\
\intertext{Specific OpCos desire to be supplied by at least two suppliers for some specific type of product code. This is ensured by the following two formulas:}
\mathlarger{\sum}_{i\in I}&F_{iop} \geq 2,\quad && \forall o \in O, p\in P \label{5}\\
\mathlarger{\sum}_{i\subset I}&x_{ijp} \geq F_{iop} G_{op},\quad && \forall i \in I, o\in O, p\in P \label{5}
\end{align}
\end{document}
Respuesta2
Aquí hay un ejemplo extendido:
\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\usepackage{lipsum}
\begin{document}
\section{Let us try}
\subsection{Stating the objective function}
%\lipsum[1]
\begin{equation}\label{1}
\begin{aligned}
\min \quad BFC \bigg(\sum_{i\in I}Fc_i u_i\bigg)
&+ BEC \biggl(\sum_{i\in I} \sum_{j \in J} \sum_{p \in P} x_{ijp} Ec_{ijp} y \biggr) \\
&+ BTC \biggl(\sum_{i\in I} \sum_{j \in J} \sum_{p \in P} x_{ijp} Tc_{ijp} \biggr) \\
&+ BWC \biggl(\sum_{i\in I} \sum_{j \in J} \sum_{p \in P} x_{ijp} Wc_{ijp} \biggr) \\
&+ BZC \biggl(\sum_{i\in I} \sum_{j \in J} \sum_{p \in P} x_{ijp} Z_{ijp} \biggr) Zc
\end{aligned}
\end{equation}
\subsection{Stating the constraints}
The first constraint ensures that the demand of each customer is satisfied:
\begin{align}\label{2}\allowdisplaybreaks
&\sum_{i\in I} x_{ijp} = D_{jpy}, \quad && \forall j \in J, p\in P, y \in Y\\
\intertext{The second formula makes sure that the maximum}
&\sum_{j\in J}\sum_{p\in P} x_{ijp} \leq u_i, \quad && \forall i \in I \label{3}
\intertext{Specific breweries desire to be supplied by at least two suppliers for some specific type
of product code. This is ensured by the following two formulas:}
&\sum_{i\in I}J_{ijp} \geq 2, \quad && \forall j \in J, p\in P \label{4}\\
&x_{ijp} \geq b_{ijp} M_{jp}\label{5}
\end{align}
\end{document}
y vea si el resultado le conviene. Si es así, puedes ampliarlo fácilmente.
Respuesta3
Mi versión, sin\mathlarger
paréntesis reducidos y algunas sugerencias más.
Por ejemplo,BFCy los símbolos similares en la primera pantalla no significan un producto de tres cantidades, sino una sola variable, por lo que \mathit
reduce el espacio entre las letras. Al contrario de lo que otros afirman, \cdot
es necesario para evitar que los símbolos sean interpretados como “una función evaluada en”.
Uno debería usar \biggl(
y \biggr)
, no solo \bigg
. De todos modos, con el tamaño normal \sum
, la \Big
versión parece mejor; agregue \,
si el subíndice puede chocar con el paréntesis.
Comprueba el último i\subset I
, que no parece encajar.
Podrías considerar
\sum_{\substack{i\in I \\ j\in J \\ p\in P}}
en lugar de la suma triple y lo mismo para las sumas dobles.
Evite líneas en blanco antes de las pantallas. No es necesario \noindent
si no hay una línea en blanco después de la pantalla (y si tiene una, entonces \noindent
estaría equivocado).
\documentclass{article}
\usepackage{amsmath}
\newcommand{\tvar}[1]{\mathit{#1}}
\begin{document}
\subsection{Stating the objective function}
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text
\begin{equation}\label{1}
\begin{split}
\min \tvar{BFC} &\cdot \Bigl(\,\sum_{i\in I} Fc_i \cdot u_i\Bigr)
+
\tvar{BEC} \cdot \Bigl(\,\sum_{i\in I}\sum_{j \in J}\sum_{p \in P}x_{ijp} \tvar{Ec}_{ijpy}\Bigr)
\\
{}+
\tvar{BTC} &\cdot \Bigl(\,\sum_{i\in I}\sum_{j \in J}\sum_{p \in P}x_{ijp} \tvar{Tc}_{ijp}\Bigr)
+
\tvar{BWC} \cdot \Bigl(\,\sum_{i\in I}\sum_{j \in J}\sum_{p \in P}x_{ijp} \tvar{Wc}_{ijp}\Bigr)
\\
{}+
\tvar{BZC} &\cdot \Bigl(\,\sum_{i\in I}\sum_{j \in J}\sum_{p \in P}x_{ijp} Z_{ijp}\Bigr) \tvar{Zc}
\end{split}
\end{equation}
\subsection{Stating the constraints}
The first constraint ensures that the demand of each customer is satisfied:
\begin{equation}\label{2}
\sum_{i\in I}x_{ijp} = D_{jpy}, \quad \forall j \in J, p\in P, y \in Y
\end{equation}
The second formula makes sure that the maximum capacity of each supplier facility
is not exceeded:
\begin{equation}\label{3}
\sum_{j\in J}\sum_{p\in P}x_{ijp} \leq u_i, \quad \forall i \in I
\end{equation}
Contracts with specific supplier facilities may agree on minimum allocation volumes.
This is ensured by the following formula:
\begin{equation}\label{4}
\sum_{j\in J}\sum_{p\in P}x_{ijp} \geq V_i, \quad \forall i \in I
\end{equation}
Specific breweries desire to be supplied by at least two suppliers for some specific
type of product code. This is ensured by the following two formulas:
\begin{equation}\label{5}
\sum_{i\in I}J_{ijp} \geq 2, \quad \forall j \in J, p\in P
x_{ijp} \geq b_{ijp} M_{jp}
\end{equation}
Specific OpCos desire to be supplied by at least two suppliers for some specific
type of product code. This is ensured by the following two formulas:
\begin{alignat}{2}
&\sum_{i\in I}F_{iop}\geq 2, &\quad& \forall o \in O, p\in P \label{6}\\
&\sum_{i\subset I}x_{ijp} \geq F_{iop}G_{op}, && \forall i \in I, o\in O, p\in P \label{7}
\end{alignat}
\end{document}
Aquí está la versión con\substack
Respuesta4
Para la primera ecuación puedes usar multline
el entorno (definido en el amsmath
paquete):
\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage{lipsum}
\begin{document}
\subsection{Stating the objective function}
\lipsum[11]
\begin{multline}\label{1}
\min \quad \mathrm{BFC}{\cdot}\bigg(\sum_{i\in I}Fc_i{\cdot} u_i\bigg)
+ \mathrm{BEC}{\cdot}\bigg(\sum_{i\in I}\sum_{j \in J}\sum_{p \in P}x_{ijp}{\cdot}Ec_{ijpy}\bigg) \\
%
+ \mathrm{BTC}{\cdot}\bigg(\sum_{i\in I}\sum_{j \in J}\sum_{p \in P}x_{ijp}{\cdot}Tc_{ijp}\bigg)
+ \mathrm{BWC}{\cdot}\bigg(\sum_{i\in I}\sum_{j \in J}\sum_{p \in P}x_{ijp}{\cdot}Wc_{ijp}\bigg) \\
%
+ \mathrm{BZC}{\cdot}\bigg(\sum_{i\in I}\sum_{j \in J}\sum_{p \in P}x_{ijp}{\cdot}Z_{ijp}\bigg){\cdot}Zc
\end{multline}
\end{document}
\subsection{Stating the constraints}
The first constraint ensures that the demand of each customer is satisfied:
\begin{align}
\mathlarger{\sum}_{i\in I}x_i_j_p = D_j_p_y, \quad && \forall j \in J, p\in P, y \in Y\label{2}
\end{align}
\noindent The second formula makes sure that the maximum capacity of each supplier facility is not exceeded:
\begin{align}
\mathlarger{\sum}_{j\in J}\mathlarger{\sum}_{p\in P}x_i_j_p \leq u_i, \quad && \forall i \in I \label{3}
\end{align}
\noindent Contracts with specific supplier facilities may agree on minimum allocation volumes. This is ensured by the following formula:
\begin{align}
\mathlarger{\sum}_{j\in J}\mathlarger{\sum}_{p\in P}x_i_j_p \geq V_i, \quad && \forall i \in I \label{3}
\end{align}
\noindent Specific breweries desire to be supplied by at least two suppliers for some specific type of product code. This is ensured by the following two formulas:
\begin{align}
\mathlarger{\sum}_{i\in I}J_i_j_p \geq 2, \quad && \forall j \in J, p\in P \label{4}\\
x_i_j_p \geq b_i_j_p M_j_p
\end{align}
\noindentSpecific OpCos desire to be supplied by at least two suppliers for some specific type of product code. This is ensured by the following two formulas:
\begin{align}
\mathlarger{\sum}_{i\in I}F_i_o_p\geq 2,\quad && \forall o \in O, p\in P \label{5}\\
\mathlarger{\sum}_{i\subset I}x_i_j_p \geq F_i_o_pG_o_p,\quad && \forall i \in I, o\in O, p\in P \label{5}
\end{align}
\end{document}
que producen:
Algunos comentarios:
- Aumentar el tamaño de algunos símbolos en la ecuación (en su caso
\sum
) no es una buena idea. Su tamaño está diseñado deliberadamente para lograr ecuaciones atractivas, así que no destruyas los esfuerzos de los diseñadores. - Supongo que
BFC
,,BTC
etc. son abreviaturas, que deberían escribirse con fuentes ascendentes, es decir, deberían escribirse como\mathrm{BFC}
`\mathbf{BTC}˙, etc. - De manera similar
c_i_j_p_y
, la notación es incorrecta. Debería ser oc_{ijpy}
(cuál resultado es el más probablemente deseado) oc_{i_{j_{p_{y}}}}
(cuál es menos probable) \cdot
Desde el punto de vista matemático , no es necesario el uso de para la multiplicación. De todos modos, si persiste en usarlos, puede reducir el espacio a su alrededor encerrándolos entre llaves (como se hace en el MWE anterior)