2

I'm having a problem with the position of the equations and the image. how come the second and third equations have an indentation and are not aligned? (in particular the second one). I think that by observing them they are not very pleasant to look at how come the figure is so detached? thanks.

\documentclass[a4paper,10pt]{article}
usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{mathtools}

%\usepackage{empheq}
\usepackage{showlabels} %%<----
\newcommand{\de}[1]{\mathrm{d}#1}
\newcommand{\Fra}[2]{\displaystyle \frac{ #1}{ #2}}
    \begin{minipage}[h]{.65\textwidth}
    In un \textit{P.B.L.}, in quiete, la forza di gravità bilancia esattamente la forza dovuta al gradiente verticale di pressione, vale pertanto l'equazione idrostatica dell'atmosfera, secondo la quale, la pressione decresce con la quota.
    \\
    Questa relazione conserva la sua validità anche in situazioni reali, ossia non statistiche: 
    \begin{subequations}
        \begin{align}
        \de{p} = -g\,\rho\de{z}\label{eq086}\qquad
        \text{\parbox{4cm}{Equazione Idrostatica}}\\
        \mathbf{p} = \rho\,R\,T = \Fra{R\,T}{V}\label{eq086.1}\\
        \rho= \Fra{\mathbf{p}}{R\,T}\label{eq086.2}\qquad
        \text{\parbox{4cm}{Equazione di Stato }}
     \end{align}
    \end{subequations}
    \end{minipage}\hfill
    %
    \begin{minipage}[h]{.35\textheight}
        \centering\raisebox{\dimexpr \topskip-\height}{%

            \includegraphics[width=0.4\textwidth]{particella/adiabatica}}
        \captionof{figure}{\\Andamento della densità\\con la quota}
    \label{fig:adiabatica}
    \end{minipage}
    \vspace{1cm}

    Combinando le due equazioni, si ottiene : 
    %
    \begin{equation}
        \setlength\fboxsep{0cm}
        \setlength\fboxrule{0pt}
        \de{p} = -g\,\Fra{\mathbf{p}}{R\,T}\de{z}\,\Rightarrow\, \Fra{\de{p}}{\de{z}}= -g\,\Fra{\textbf{p}}{R\,T}\label{eq086.3} \\
    \end{equation}

enter image description here

-------------------UPDATE-------------------

I tried to write the code using wrapfigure as suggested by GuM. I hope it is correct or needs a review?

\begin{minipage}[h]{.95\textwidth}

    \begin{wrapfigure}[25]{r}{3.5cm}
        \includegraphics[width=3.5cm]{adiabatica}
        \captionof{figure}{Andamento della densit\`{a} con la quota}
        \label{fig:adiabatica}
    \end{wrapfigure}%\hfill 

    In un \textit{P.B.L.}, in quiete, la forza di gravità bilancia esattamente la forza dovuta al gradiente verticale di pressione, vale pertanto l'equazione idrostatica dell'atmosfera, secondo la quale, la pressione decresce con la quota.\\
    Questa relazione conserva la sua validità anche in situazioni reali, ossia non statistiche: 

    \begin{subequations}
        \begin{align}
        \de{p} &= -g\,\rho\de{z}
        && \text{Equaz.\ Idrostatica} 
        \label{eq086} \\
        \mathbf{p} &= \rho RT = \Fra{RT}{V}\label{eq086.1} \\
        \rho &= \Fra{\mathbf{p}}{RT}\label{eq086.2}
        && \text{Equaz.\ di Stato}
        \end{align}
    \end{subequations}
\end{minipage}\quad\hfill
\bigskip\bigskip\bigskip

Combinando le due equazioni, si ottiene: 
%
\begin{equation}
\setlength\fboxsep{0cm}
\setlength\fboxrule{0pt}
\de{p} = -g\,\Fra{\mathbf{p}}{R\,T}\de{z}\,\Rightarrow\, \Fra{\de{p}}{\de{z}}= -g\,\Fra{\textbf{p}}{R\,T}\label{eq086.3} \\
\end{equation}

enter image description here

  • 1
    I started adding a preamble so I could compile your file and propose a solution, but I gave up. I managed to provide the missing commands and \includepackage lines, but I can't quite reproduce your output, as I don't know what your page geometry and other parameters are set to, or what class you're using. Which is a long-winded way of saying: Please expand the sample code to a MWE. Also, replace the included figure by something like example-image-10x16. The helpful folks here need your help to let them help you! – Harald Hanche-Olsen Feb 7 at 17:45
  • 1
    One comment, though: Your {align} environment is conspicuously lacking any ampersand (&) characters for the alignment. That might be a big part of your problem, right there. – Harald Hanche-Olsen Feb 7 at 17:47
5

You need &s to mark the alignment points (2n – 1 &s for n alignment points). Here is a possibility, with a recreated preamble. However, note that, with the chosen lengths the figure overflows into the margin.

\documentclass[a4paper, italian]{article}
\usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[demo]{graphicx}
\usepackage{caption}
    \usepackage{mathtools}
\newcommand{\de}[1]{\mathrm{d}#1}
\let\Fra=\frac

\begin{document}

\begin{minipage}[h]{.65\textwidth}
In un \textit{P.B.L.}, in quiete, la forza di gravità bilancia esattamente la forza dovuta al gradiente verticale di pressione, vale pertanto l'equazione idrostatica dell'atmosfera, secondo la quale, la pressione decresce con la quota.
\\
Questa relazione conserva la sua validità anche in situazioni reali, ossia non statistiche:
\begin{subequations}
    \begin{align}
    \de{p} & = -g\,\rho\de{z}\label{eq086} & & \text{Equazione Idrostatica}\\
    \mathbf{p} & = \rho\,R\,T= \mathrlap{\Fra{R\,T}{V}}\label{eq086.1}\\
    \rho & = \Fra{\mathbf{p}}{R\,T}\label{eq086.2} & & \text{Equazione di Stato}
 \end{align}
\end{subequations}
\end{minipage}\hfill
%
\begin{minipage}[h]{.35\textheight}
    \centering\raisebox{\dimexpr \topskip-\height}{%
        \includegraphics[width=0.4\textwidth]{particella/adiabatica}}
    \captionof{figure}{\\Andamento della densità\\con la quota}
\label{fig:adiabatica}
\end{minipage}
\vspace{1cm}

Combinando le due equazioni, si ottiene :
%
\begin{equation}
    \setlength\fboxsep{0cm}
    \setlength\fboxrule{0pt}
    \de{p} = -g\,\Fra{\mathbf{p}}{R\,T}\de{z}\,\Rightarrow\, \Fra{\de{p}}{\de{z}}= -g\,\Fra{\textbf{p}}{R\,T}\label{eq086.3} \\
\end{equation}

\end{document} 

enter image description here

4

Have a look at this (same remarks as Bernard’s):

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage[italian]{babel}
\usepackage{amsmath}
% \usepackage{caption}
\usepackage{capt-of}

\usepackage{mwe} % for this MWE only

\newcommand*{\de}[1]{\mathop{}\!\mathrm{d}#1} % stub
\newcommand*{\Fra}[2]{\frac{#1}{#2}} % ???



\begin{document}

\noindent\begin{minipage}[c]{.6\textwidth}
In un \textit{P.B.L.}, in quiete, la forza di gravit\`{a} bilancia esattamente
la forza dovuta al gradiente verticale di pressione, vale pertanto l'equazione
idrostatica dell'atmosfera, secondo la quale, la pressione decresce con la
quota.

Questa relazione conserva la sua validit\`{a} anche in situazioni reali, ossia
non statistiche:
    \begin{subequations}
        \begin{align}
            \de{p} &= -g\,\rho\de{z}
                && \text{Equaz.\ Idrostatica} 
                \label{eq086} \\
            \mathbf{p} &= \rho RT = \Fra{RT}{V}\label{eq086.1} \\
            \rho &= \Fra{\mathbf{p}}{RT}\label{eq086.2}
                && \text{Equaz.\ di Stato}
        \end{align}
    \end{subequations}
\end{minipage}\quad\hfill
%
\begin{minipage}[c]{.35\textwidth}
    \centering
    \includegraphics[width=0.8\linewidth]{image}
    \captionof{figure}{Andamento della densit\`{a} con la quota}
    \label{fig:adiabatica}
\end{minipage}

\bigskip

Combinando le due equazioni, si ottiene: 
%
\begin{equation}
    \setlength\fboxsep{0cm}
    \setlength\fboxrule{0pt}
    \de{p} = -g\,\Fra{\mathbf{p}}{R\,T}\de{z}\,\Rightarrow\, \Fra{\de{p}}{\de{z}}= -g\,\Fra{\textbf{p}}{R\,T}\label{eq086.3} \\
\end{equation}

\end{document}

Here’s the output:

Output of the code

Note the following points, among the others:

  • I use the [c] position specifier to align the two minipages at their vertical center, without having to tamper with the vertical space inside the rightmost one;

  • do not use \\ to separate paragraphs inside the minipages;

  • I use & and && inside the align environment, as Bernard has already taught you;

  • I replaced \textheight with \textwidth in the “width” argument of the second minipage environment (!!!);

  • finally, I added \noindent before the first minipage (I had previously overlooked this!).

However, you are trying to bypass (La)TeX pagination methods by hand in a way I deem incorrect; are you aware of the wrapfig package?


Update

Here’s an example of how you could use the wrapfigure environment (requires the wrapfig package). Note that, owing to the unusual height of the group of equations, it is advisable to specify explicitly the number of “virtual lines” in the narrower part: this is done via the first optional argument of the wrapfigure environment. In this case, a value of 10 seems adequate. Recall that equations are assumed to take up the equivalent of three lines.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage[italian]{babel}
\usepackage{amsmath}
% \usepackage{caption}
\usepackage{capt-of}
\usepackage{wrapfig}

\usepackage{mwe} % for this MWE only

\newcommand*{\de}[1]{\mathop{}\!\mathrm{d}#1} % stub
\newcommand*{\Fra}[2]{\frac{#1}{#2}} % ???



\begin{document}

Testo che precede la parte nella quale si vuole inserire la figura a margine.
Si assume che la figura debba stare nel margine \emph{esterno}
(\( \texttt{o}=\textit{outer} \)).

\begin{wrapfigure}[10]{o}{.35\textwidth}
    \centering
    \includegraphics[width=0.8\linewidth]{image}
    \captionof{figure}{Andamento della densit\`{a} con la quota}
    \label{fig:adiabatica}
\end{wrapfigure}

In un \textit{P.B.L.}, in quiete, la forza di gravit\`{a} bilancia esattamente
la forza dovuta al gradiente verticale di pressione, vale pertanto l'equazione
idrostatica dell'atmosfera, secondo la quale, la pressione decresce con la
quota.

Questa relazione conserva la sua validit\`{a} anche in situazioni reali, ossia
non statistiche:
\begin{subequations}
    \begin{align}
        \de{p} &= -g\rho\de{z}
            && \text{Equaz.\ Idrostatica} 
            \label{eq086} \\
        \mathbf{p} &= \rho RT = \Fra{RT}{V}\label{eq086.1} \\
        \rho &= \Fra{\mathbf{p}}{RT}\label{eq086.2}
            && \text{Equaz.\ di Stato}
    \end{align}
\end{subequations}

Combinando le due equazioni, si ottiene
(aggiungo questo commento al solo scopo
di dimostrare che siamo tornati alla giustezza piena):
%
\begin{equation}
%     \setlength\fboxsep{0cm} % ???
%     \setlength\fboxrule{0pt}
    \de{p} = -g\Fra{\mathbf{p}}{RT}\de{z}
        \quad\Longrightarrow\quad
        \Fra{\de{p}}{\de{z}}= -g\Fra{\mathbf{p}}{RT}
        \label{eq086.3}
        % \\ % ??? (!!!)
\end{equation}

\end{document}

Note also that it is a very bad idea to use labels like eq086.3: always use symbolic labels.

The output for the second example follows:

Output for the second example

  • Thank you for the precious and very interesting very interesting exhibition. I use wrapfigure but I have difficulty using it, maybe I have not acquired a good practice – Antonio Feb 7 at 19:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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