Modérateur: Modérateurs_LaTeX
cafeadicto a écrit:Bonsoir,
Est-il possible d'aligner à gauche une formule mathématique tout en gardant l'alignement vertical des membres de la formule comme avec "\begin{eqnarray}...\end{eqnarray}" et les "&", je veux dire par là décaler mes équations tout à gauche, en gardant les signes "=" les uns en dessous des autres?
D'autre part, comment réduire l'espace entre un texte et des équations (toujours avec) "hors ligne"?
Merci d'avance pour vos réponses...
% !TEX TS-program = pdflatex
% !TEX encoding = Latin1
% \makeatletter\def\input@path{{chapitres/}{images/}}\makeatother
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,%
hmargin={1cm,1cm},%
vmargin={1cm,1cm},%
headheight=15pt,%
%includeheadfoot,%
nohead,nofoot]{geometry}
\setlength{\parindent}{0pt}
\usepackage{amsmath}
\usepackage{calc}
\makeatletter
\newlength{\boxed@align@width}
\newcommand{\boxedalign}[2]{
#1 & \setlength{\boxed@align@width}
{\widthof{$\displaystyle#1$}+\fboxsep+\fboxrule}
\hspace{-\boxed@align@width}
\addtolength{\boxed@align@width}{-\fboxsep-\fboxrule}
\boxed{\vphantom{#1}
\hspace{\boxed@align@width}#2}}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{en début de ligne}
$\begin{aligned}
5-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
5-(x+2)^2&=-x^2-4x+1
\end{aligned}$
\section{centré sur une ligne}
Dans une ligne, aussi :
$\begin{aligned}
5-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
5-(x+2)^2&=-x^2-4x+1
\end{aligned}$
avec un centrage sur la ligne par défaut.
\section{aligné sur le bas d'une ligne}
Dans une ligne, aussi :
$\begin{aligned}[b]
5-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
5-(x+2)^2&=-x^2-4x+1
\end{aligned}$
avec la possibilité d'aligner sur le bas de la ligne.
\section{aligné sur le haut d'une ligne}
Dans une ligne, aussi :
$\begin{aligned}[t]
5-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
5-(x+2)^2&=-x^2-4x+1
\end{aligned}$
avec la possibilité d'aligner sur le bas de la ligne.
\section{avec un résultat entouré}
$\begin{aligned}
5-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
\boxedalign{5-(x+2)^2}{=-x^2-4x+1}
\end{aligned}$
\end{document}\newlength{\boxed@align@width}
\newcommand{\boxedalign}[2]{
#1 &= \setlength{\boxed@align@width}
{\widthof{$\displaystyle#1 \,=$}+\fboxsep+\fboxrule}
\hspace{-\boxed@align@width}
\addtolength{\boxed@align@width}{-\fboxsep-\fboxrule}
\boxed{\vphantom{#1}
\hspace{\boxed@align@width} #2}}projetmbc a écrit:tu as oublié le signe EGAL dans l'équation encadrée.
projetmbc a écrit:J'ai fait la petite modif. suivante qui ...
\boxedalign{5-(x+2)^2}{-x^2-4x+1}\boxedalign{5-(x+2)^2}{=-x^2-4x+1}Parce que pg l'a décidé ainsi !projetmbc a écrit:Ok mais dans ce cas, pourquoi deux arguments ?
GMaths a écrit:A propos de eqnarray, un peu de lecture : http://people.math.jussieu.fr/~mpg/latex/tips#eqnarray
GMaths a écrit:Parce que pg l'a décidé ainsi !
Plus sérieusement : pour le problème d'alignement, il me semble.
\documentclass[11pt]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,%
hmargin={1cm,1cm},%
vmargin={1cm,1cm},%
headheight=15pt,%
%includeheadfoot,%
nohead,nofoot]{geometry}
\setlength{\parindent}{0pt}
\usepackage{amsmath}
\usepackage{calc}
\makeatletter
\newlength{\boxed@align@width}
\newcommand{\boxedalign}[1]{}
\def\boxedalign#1{\@boxedalign#1\@nil}
\def\@boxedalign#1\@nil{
#1 & \setlength{\boxed@align@width}
{\widthof{$\displaystyle#1$}+\fboxsep+\fboxrule}
\hspace{-\boxed@align@width}
\addtolength{\boxed@align@width}{-\fboxsep-\fboxrule}
\boxed{\vphantom{#1}
\hspace{\boxed@align@width}#2}}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{en début de ligne}
$\begin{aligned}
5-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
5-(x+2)^2&=-x^2-4x+1
\end{aligned}$
\section{centré sur une ligne}
Dans une ligne, aussi :
$\begin{aligned}
5-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
5-(x+2)^2&=-x^2-4x+1
\end{aligned}$
avec un centrage sur la ligne par défaut.
\section{aligné sur le bas d'une ligne}
Dans une ligne, aussi :
$\begin{aligned}[b]
5-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
5-(x+2)^2&=-x^2-4x+1
\end{aligned}$
avec la possibilité d'aligner sur le bas de la ligne.
\section{aligné sur le haut d'une ligne}
Dans une ligne, aussi :
$\begin{aligned}[t]
5-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
5-(x+2)^2&=-x^2-4x+1
\end{aligned}$
avec la possibilité d'aligner sur le bas de la ligne.
\section{avec un résultat entouré}
$\begin{aligned}
5-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
\boxedalign{5-(x+2)^2&=-x^2-4x+1}
\end{aligned}$
\end{document}pg a écrit:Si on préfère une syntaxe du type \boxedalign{A&=B}, c'est possible aussi : ...
GMaths a écrit:A propos de eqnarray, un peu de lecture : http://people.math.jussieu.fr/~mpg/latex/tips#eqnarray
\begin{displaymath}\displaywidth=.5\textwidth
\begin{aligned}
\frac{5}{2}-(x+2)^2&=5-(x^2+4x+4)\\
&=5-x^2-4x-4)\\
5-(x+2)^2&=-x^2-4x+1
\end{aligned}
\end{displaymath}
\centering
\cornersize{1}
ovalbox{%\makebox[15cm][1]
{mon texte}} Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 2 invités