我怎样才能确保单位正确位于相应术语之下?
\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}
答案1
我在这里通过将单元堆叠在每个术语下来实现。已编辑以合并siunitx
调用,以自定义形式调用\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}
如果在调用中更改\dfrac
为,则单位可以以压缩形式呈现:\tfrac
\sisetup
请注意,代码中指定了到下划线的基线跳跃\setstackgap{L}{2\baselineskip}
。
答案2
您应该使用siunitx
单位;对于对齐,使用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}