2

how can I center the first equation Max $Z = 0.15x_{1} + 0.12x_{2} + 0.1x_{3} + 0.05x_{4} + 0.08x_{5}$ and the text "s.a" with the other equations below ?

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[spanish,es-tabla]{babel} % espanol
\decimalpoint
\usepackage[utf8]{inputenc}
\usepackage{graphicx} % graficos

\usepackage{amsmath}


\begin{document}
Luego el modelo matemático queda planteado como se muestra a continuación:\\

Max $Z = 0.15x_{1} + 0.12x_{2} + 0.1x_{3} + 0.05x_{4} + 0.08x_{5}$

s.a

\begin{equation}
 x_{1} + x_{2} + x_{3} + x_{4} + x_{5} \leq 1.000.000
\label{eqn:p1-r1}
\end{equation}
\begin{equation}
 x_{1} + x_{2} \leq 0.3(x_{1} + x_{2} + x_{3} + x_{4} + x_{5})
\label{eqn:p1-r2}
\end{equation}
\begin{equation}
 x_{4} \geq x_{5}
\label{eqn:p1-r3}
\end{equation}
\begin{equation}
 x_{3} + x_{4} \leq 0.5(x_{1} + x_{2} + x_{3} + x_{4} + x_{5})
\label{eqn:p1-r4}
\end{equation}
\begin{equation}
  x_{4} \geq 0.25(x_{1} + x_{2} + x_{3} + x_{4} + x_{5})
\label{eqn:p1-r5}
\end{equation}

\begin{itemize}
\item Resuelva el problema mediante el software de optimización OPL –CPLEX, y entregue la Solución y Valor
Optimo.\\
\end{itemize}

\end{document}
  • 1
    Welcome to TeX SX! Could you post a full compilable code? – Bernard Nov 23 '18 at 19:55
  • 1
    @EmiliOrtega please add a compilable MWE. Though not THE way to typeset these type of equation. You can do it by using display-math style. Replace $...$ by \[...\]. – Raaja_is_at_topanswers.xyz Nov 23 '18 at 19:55
  • I added compilable code right now! @Raaja I didn't get what you meant by "display-math" – EmiliOrtega Nov 23 '18 at 20:37
  • since you're using amsmath, you might use the gather environment (with \\ to separate lines) instead of entering each line as a separate equation. and don't leave a blank line before any single or multi-line equation block. the blank line will not prevent a page break (which is not desirable in such a location), and the use of a multi-line environment like gather will allow better control over page breaks between lines. – barbara beeton Nov 23 '18 at 22:59
2

Method 1: Not-so-correct way is to use display-math style as in:

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[spanish,es-tabla]{babel} % espanol
\decimalpoint
\usepackage[utf8]{inputenc}
\usepackage{graphicx} % graficos

\usepackage{amsmath}

\begin{document}
Luego el modelo matemático queda planteado como se muestra a continuación:\\

 \[\max Z = 0.15x_{1} + 0.12x_{2} + 0.1x_{3} + 0.05x_{4} + 0.08x_{5}\]

s.a

\begin{equation}
 x_{1} + x_{2} + x_{3} + x_{4} + x_{5} \leq 1.000.000
\label{eqn:p1-r1}
\end{equation}
\begin{equation}
 x_{1} + x_{2} \leq 0.3(x_{1} + x_{2} + x_{3} + x_{4} + x_{5})
\label{eqn:p1-r2}
\end{equation}
\begin{equation}
 x_{4} \geq x_{5}
\label{eqn:p1-r3}
\end{equation}
\begin{equation}
 x_{3} + x_{4} \leq 0.5(x_{1} + x_{2} + x_{3} + x_{4} + x_{5})
\label{eqn:p1-r4}
\end{equation}
\begin{equation}
  x_{4} \geq 0.25(x_{1} + x_{2} + x_{3} + x_{4} + x_{5})
\label{eqn:p1-r5}
\end{equation}

\begin{itemize}
\item Resuelva el problema mediante el software de optimización OPL –CPLEX, y entregue la Solución y Valor
Optimo.\\
\end{itemize}

\end{document}

with which you will get:

enter image description here

Method 2: The (IMO) current way:

\documentclass{article}
\usepackage{amsmath}
%https://tex.stackexchange.com/questions/368570/typesetting-an-optimisation-problem
\begin{document}
    \begin{subequations}
        \begin{alignat}{2}
        &\!\max_{m(t)}        &\qquad& F(t)=m(t)a(t)^2\\
        &\text{s.a} &      &  E(t)=m(t)c(t)^2,\\
        &                  &      &  m(t)=\text{If I knew I would be the great E}
        \end{alignat}
    \end{subequations}
\end{document} 

to get:

enter image description here

| improve this answer | |
  • and how can I move "s.a" at the same horizontal position than "max Z" ? – EmiliOrtega Nov 23 '18 at 20:50
  • @EmiliOrtega Updated the answer. – Raaja_is_at_topanswers.xyz Nov 23 '18 at 20:54
  • Thanks, I have a question, what is that "&" operator for that you use inside of "alignat" ? – EmiliOrtega Nov 24 '18 at 21:35
  • @EmiliOrtega It is mostly like a definition or a marker to define the alignment (to the best of my understanding) and you are welcome! – Raaja_is_at_topanswers.xyz Nov 24 '18 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.