2

How can i make that the units are right under the corresponding term?

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{tkz-euclide}
\usepackage{geometry}
\geometry{left = 30mm, right = 30mm}    
\usepackage[it]{caption}
\usepackage{subfig}
\usepackage{showframe} % just for demonstration of hfil vs hfill and centering...
\usepackage{microtype}

\begin{document}
\[
-E(s)I\frac{\partial^4 \vec{w}(s,t)}{\partial s^4} + \overline{m}(s) \frac{\partial^2 \vec{w}(s,t)}{\partial t^2}  + c(s) \frac{\partial \vec{w}(s,t)}{\partial t} = \widehat{m}\vec{a}(t)
\]
\[
[\frac{kgm^3}{s^2}][\frac{1}{m^3}] + [\frac{kg}{m}][\frac{m}{s^2}] + [\frac{kg}{ms}][\frac{m}{s}] = [\frac{kg}{m}][\frac{m}{s^2}]
\]  
\end{document}
  • Please make some that actually compiles. And perhaps you should make your example a lot more minimal, there are a lot of packages here that is not relevant for a question about equation alignment – daleif Jan 14 '16 at 12:40
  • Runaway argument? {{document} ! Paragraph ended before \end was complete. <to be read again> \par l.131 – David Carlisle Jan 14 '16 at 12:41
  • as a side note, please learn to use siunitx to typeset units, there are rules for units. – daleif Jan 14 '16 at 12:41
1

I do it here by stacking the unit under each term. EDITED to incorporate siunitx calls, invoked in customized form as \mySI{<units>}.

\documentclass[11pt,a4paper]{article}

%%%%%%%%%%%%%%%%%%%
%%% Usepackages %%%
%%%%%%%%%%%%%%%%%%%

\usepackage[utf8]{inputenc}                 % Deutsche Tastatur / Umlaute
\usepackage[T1]{fontenc}                    % Erweiterte Deutsche Sprache (Umlaute, Sonderzeichen etc)
\usepackage[ngerman]{babel}                 % Deutscher Schriftsatz, Silbentrennung, neue Deutsche          Rechtschreibung etc.
\usepackage{lmodern}

\usepackage{graphicx}                       % Für Einbindung von Grafiken
\usepackage[pdfborder={0 0 0}]{hyperref}    % Verlinkt das Inhaltsverzeichnis ohne roten Rahmen

% Spezialpakete
\usepackage{fp}
\usepackage{tikz}
\usepackage{xcolor}
% TikZ-Bibliotheken
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{decorations.text}
\usepackage{tkz-euclide}


\usepackage{geometry}                       % Für Seitenränder
\geometry{left = 30mm, right = 30mm}    

\usepackage{scrpage2}                       % Für Kopf und Fußzeilen

\usepackage{listings}                       % Für Quellcode
\usepackage{mathcomp}                       % Für Matrizen
\usepackage{tabularx}                       % Für Tabellen
\usepackage{amsmath}                        % Befehle für Formellayout
\usepackage{amssymb}                        % Mathematische Sonderzeichen
\usepackage{amsthm}                         % Für Theoremstyle
\usepackage{floatflt}                       % Text um Bild
\usepackage[small, it]{caption}             % Caption von Bild ist it
\usepackage{cite}                           % Literaturverzeichnis
\usepackage{listings}                       % Für Quellcode

\usepackage{subfig}

%%% Für Definitionen %%%
\theoremstyle{definition}
\newtheorem{definition}{Definition}

%%% Für Sätze %%%
\theoremstyle{theorem}
\newtheorem{theorem}{Satz}

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Kopf- und Fußzeile %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%\pagestyle{scrheadings}
%\clearscrheadings
%
%% Kopfzeile %
%\ihead{\leftmark}
%\automark{section}
%%\ohead{\includegraphics[trim = 0mm 0mm 0mm 20mm, height = 5mm]{./images/FAU.png}}
%\headsep=20mm  % Größe der Kopfzeile festlegen
%
%% Fußzeile %
%\cfoot{Gruppe: \\
%      Erdbebensicheres Bauen}
%\ifoot{\today}
%\ofoot{Seite \pagemark}
%\footskip=15mm % Größe der Fußzeile festlegen

%%%%%%%%%%%%%%%%%%%%%%%%%
%%% For code listings %%%
%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%
%%% Selbst eingefügt %%%
%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xcolor,soul}        % highlighting
\usepackage{listings}           % listings print source code

% define colors for source code list
\definecolor{colKeys}{rgb}{0,0,1}
\definecolor{colIdentifier}{rgb}{0,0,0}
\definecolor{colComments}{rgb}{0,1,0.3}
\definecolor{colString}{rgb}{0,0.5,0}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}

\lstset{language=Matlab,
   keywords={persistent,zeros},
   float=hbp,
   basicstyle=\ttfamily\small,
   identifierstyle=\color{colIdentifier},
   keywordstyle=\color{blue},
   commentstyle=\color{dkgreen},
   columns=flexible,
   tabsize=2,
   frame=single,
   numbers=left,
   extendedchars=true,
   showspaces=false,
   numberstyle=\tiny\color{gray},
   stepnumber=1,
   numbersep=10pt,
   showspaces=false,
   showstringspaces=false,
   breakautoindent=true}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Sonstige Commands etc %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%\linespread{1.2}
%\pagenumbering{Roman}

\newcommand{\correct}[1]{\textcolor{red}{#1}}
\usepackage{stackengine,siunitx}
\sisetup{
  per-mode=fraction,
  fraction-function=\dfrac
}
\stackMath
\newcommand\mySI[1]{\Bigl[\SI{}{#1}\Bigr]}
\begin{document}
\noindent
\begin{frame}{Formulierung des Modells}
\[
\def\stacktype{L}
\setstackgap{L}{2\baselineskip}
\stackunder{-E(s)}{\mySI{\kg \m\cubed \per \s\squared}}
\stackunder{I\dfrac{\partial^4 \vec{w}(s,t)}{\partial s^4}}{\mySI{\per \m\cubed}}
\stackunder{{}+{}}{+}
\stackunder{\overline{m}(s)}{\mySI{\kg\per\m}}
\stackunder{\dfrac{\partial^2 \vec{w}(s,t)}{\partial t^2}}{\mySI{\m\per\s\squared}}
\stackunder{{}+{}}{+}
\stackunder{c(s)}{\mySI{\kg\per\m\per\s}}
\stackunder{\dfrac{\partial \vec{w}(s,t)}{\partial t}}{\mySI{\m\per\s}}
\stackunder{{}={}}{=}
\stackunder{\widehat{m}}{\mySI{\kg\per\m}}
\stackunder{\vec{a}(t)}{\mySI{\m\per\s\squared}}
\]
\end{frame}
\end{document}

enter image description here

If you change \dfrac to \tfrac in the \sisetup call, then the units can be presented in compressed form:

enter image description here

Note that the baselineskip to the underset line is specified in the code \setstackgap{L}{2\baselineskip}.

1

You should use siunitx for the units; for the alignment, use an array:

\documentclass[11pt,a4paper]{article}
\usepackage{array,siunitx}

\begin{document}

\[
\setlength{\arraycolsep}{0pt}
\sisetup{per-mode=fraction}
\begin{array}{
 >{\displaystyle}c
 >{\displaystyle}c
 *{3}{
   >{{}}c<{{}}
   >{\displaystyle}c
   >{\displaystyle}c
 }
}
-E(s)           & I\frac{\partial^4 \vec{w}(s,t)}{\partial s^4}
 & + &
\overline{m}(s) & \frac{\partial^2 \vec{w}(s,t)}{\partial t^2}
 & + &
c(s)            & \frac{\partial \vec{w}(s,t)}{\partial t}
 & = &
\widehat{m}     &\vec{a}(t)
\\[2ex]
\biggl[\si{\kilogram\cubed\per\second\squared}\biggr] &
  \biggl[\si{\per\meter\cubed}\biggr]
 & + &
\biggl[\si{\kilogram\per\meter}\biggr] &
  \biggl[\si{\meter\per\second\squared}\biggr]
 & + &
\biggl[\si{\kilogram\per\meter\per\second}\biggr] &
  \biggl[\si{\meter\per\second}\biggr]
 & = &
\biggl[\si{\kilogram\per\meter}\biggr] &
  \biggl[\si{\meter\per\second\squared}\biggr]
\end{array}
\]  
\end{document}

enter image description here

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.