PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : place equation in desired position



Yang
11-05-2007, 14:05
hallo there,

I am just woundering, whether there is a way to place an equation in a desired position, let's say, 5cm from left.

thanks for any help.

Yang

countbela666
11-05-2007, 14:27
Hi Yang,

here's a short example that only works with the fleqn class option:

\documentclass[fleqn,english]{article}
\usepackage{babel,blindtext,amsmath}
\begin{document}
\blindtext
{\mathindent=5cm
\begin{align}
a^2+b^2&=c^2 \qquad\text{5\,cm from left}\\
d&=e
\end{align}}
%
\blindtext
{\mathindent=0cm
\begin{align}
a^2+b^2&=c^2 \qquad\text{0\,cm from left}\\
d&=e
\end{align}}
%
\blindtext
\begin{align}
a^2+b^2&=c^2 \qquad\text{normal flushleft}\\
d&=e
\end{align}
\blindtext
\end{document}Regards
Marcel

Yang
12-05-2007, 09:05
hallo Marcel,

thanks soooooooooo much, that was great help.

but the problem is I just want change only some of the equations in the desired place, other remain centering. Using \mathindent changed all the equations to be placed, for example, 5cm from left.

I tried to add \centering in the front of other equations, but it didnt work.

anyone can help me?

thanks...

rais
13-05-2007, 07:04
Hi Yang,


but the problem is I just want change only some of the equations in the desired place, other remain centering. Using \mathindent changed all the equations to be placed, for example, 5cm from left.

well, the environments shown here---except equation, that is---aren't usually taken for single lined equations, and some strange things may happen if you have some different heights or try leqno/fleqn, but as an idea...


\documentclass{article}
\usepackage{amsmath}
\newlength{\ieqind}
\newenvironment{indeq}[1][2cm]{%
\setlength{\ieqind}{#1}
\addtolength{\ieqind}{-\multlinegap}
\multline%
\hspace{\ieqind}
}{
\\[-\baselineskip]\endmultline%
}
\begin{document}
\begin{equation}
c^2 = a^2 + b^2
\end{equation}
\noindent\rule{2cm}{1pt}
\begin{indeq}
c^2 = a^2 + b^2
\end{indeq}
\noindent\rule{2cm}{1pt}
\begin{flalign*}
\hspace{2cm}c^2 &= a^2 + b^2
& \vphantom{a}&\phantom{=}\vphantom{b}
\end{flalign*}
\end{document}

Similarily, you could use the flalign-environment for a numbered version, should my indeq environment give you too much trouble;-)
To make the difference more apparent, I used 2 cm, instead of 5... but that is easily adapted.
Regards,