
Soy principiante en LaTex y he escrito el siguiente código:
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage[english, french, greek]{babel}
\begin{document}
\selectlanguage{english}
\title{Physics assignment}
\author{me}
\date{\today}
\maketitle
\section*{Excercise 1}
\selectlanguage{greek}
$m = 5kg$
$t = 0sec$: $\vec{υ} = 2m/s$
$t' = 2sec$: $\vec{υ} = 12m/s$
$\mu = 0,2$
$\vec{g} = 10m/s^2$
\end{document}
Esta es la salida del código. ¿Cómo puedo hacer para que la primera línea de la sección, "m = 5kg", se alinee con el resto de las líneas?
Cualquier ayuda es muy apreciada.
Respuesta1
Hola @PuperHacker y bienvenido a TeX-SE.
Como eres principiante, vayamos paso a paso.
Estándares
Existen muchos estándares en todo el mundo. El estándar de LaTeX depende de la clase ynormalmenteestán relacionados con estándares comunes en EE. UU. Soy de Brasil y el estándar común aquí (el que se enseña en las escuelas primarias) estodos los párrafos están sangrados.
Entonces, primer comando básico\usepackage{indentfirst}
Este es un MWE (ejemplo de trabajo mínimo). OBS: \usepackage{lipsum}
genera texto ficticio.
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{indentfirst} %(un)comment this line to test
\usepackage{lipsum}
\begin{document}
\section{title}
\lipsum[1]
\lipsum[2]
\end{document}
Con\usepackage{indentfirst}
Sin\usepackage{indentfirst}
Ecuaciones y Unidades
Existen muchos métodos para ingresar matemáticas en LaTeX.
Debo ser honesto, lo aprendí siunitx
solo después de comenzar mi propio conjunto de comandos de unidades, por lo que podría haber algunos métodos mejores para usar el paquete siunitx
.
Para obtener más información, consulte:CTAN - siunitx.
Un NOSOTROS no tan mínimo sigue
\documentclass{article}
\usepackage{amsmath}
\usepackage{indentfirst}
\usepackage{siunitx}
\begin{document}
\section{title}
Text $m = 5 kg$ does not result in the same as $m = 5$ kg.
With a blank line (not recommended)
\begin{equation}
m = 5 kg
\end{equation}
Without a blank line (recommended)
\begin{equation}
m = 5 kg
\end{equation}
Let's test some text commands in math mode.
Using align
\begin{align}
m & = 5 kg \\
m & = 5 \operatorname{kg} \\
m & = 5 \text{kg} \\
m & = 5 \textrm{kg} \\
m & = 5 \mathrm{kg}
\end{align}
Using split
\begin{equation}
\begin{split}
m & = 5 kg \\
m & = 5 \operatorname{kg} \\
m & = 5 \text{kg} \\
m & = 5 \textrm{kg} \\
m & = 5 \mathrm{kg}
\end{split}
\end{equation}
Align and split don't interfere with spacing, but they label equations differently.
\clearpage
And now some siunitx commands and spacing
\begin{align}
m & = 5 \si{\kilogram} \\
m & = 5 \ \si{\kilogram} \\
m & = 5 \, \si{\kilogram} \\
m & = 5 \; \si{\kilogram} \\
m & = 5 \quad \si{\kilogram} \\
m & = 5 \qquad \si{\kilogram}
\end{align}
And now some siunitx commands to better spacing comparing the ones without it.
\begin{align}
m & = 5\si{\kilogram} \\
m & = \SI{5}{\kilogram} \\
\vec{u} & = 12 \si{m/s} \\
\vec{u} & = \SI{12}{m/s} \\
\vec{u} & = \SI{12}{m \per s} \\
\vec{u} & = \SI{12}{\metre\per\second}
\end{align}
\end{document}
y los resultados son
Desde mi punto de vista, siunitx
tiene la mayor cantidad de opciones y es un paquete bien mantenido. Si no desea utilizarlo, la segunda mejor opción sería \operatorname{}
gestionar mejor el espaciado.
Respuesta2
Con align*
y siunitx
:
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage[english, french, greek]{babel}
\usepackage{amsmath}
\usepackage{siunitx}
\begin{document}
\selectlanguage{english}
\section*{Excercise 1}
\selectlanguage{greek}
\begin{align*}
m &= \SI{5}{\kg}\\
t &= \SI{0}{\s}: \vec{υ} = \SI{2}{\m\per\s}\\
t' &= \SI{2}{\s}: \vec{υ} = \SI{12}{\m\per\s} \\
\mu &= 0,2\\
\vec{g} &= \SI{10}{\m\per\s\squared}
\end{align*}
\end{document}
Respuesta3
Generalmente, querrás alinearte con el =
letrero, como lo mostró Leandris. Ocasionalmente, sin embargo, es posible que desee alinear tanto el lado izquierdo de las variables como el =
signo.
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage[english, french, greek]{babel}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{tabstackengine}
\TABstackMath
\begin{document}
\selectlanguage{english}
\section*{Exercise 1}
\selectlanguage{greek}
\[
\TABbinary
\setstackaligngap{0pt}
\setstackgap{L}{1.2\baselineskip}
\alignCenterstack{
&m&=& \SI{5}{\kg}\\
&t&=& \SI{0}{\s}: \vec{υ} = \SI{2}{\m\per\s}\\
&t'&=& \SI{2}{\s}: \vec{υ} = \SI{12}{\m\per\s} \\
&\mu&=& 0,2\\
&\vec{g}&=& \SI{10}{\m\per\s\squared}
}
\]
\end{document}