LoginSignup
2
1

More than 5 years have passed since last update.

LaTeXで連立1次方程式

Last updated at Posted at 2017-06-24

私家版のしょぼいマクロ

example.tex
\documentclass{jsarticle}

\makeatletter
\newenvironment{syslineq}[1][10]{%
  \mbox\bgroup\begin{math}\left\{%
  \renewcommand{\arraycolsep}{.15em}%
  \begin{array}{*{#1}{cr}l}
}{%
  \end{array}%
  \right.\end{math}\egroup%
}
\makeatother

\begin{document}

\begin{syslineq}
 & 7 x &-& y & &     &=& 1 \\
 &     & & y &+&   z &=& 2 \\
-&   x & &   &+& 8 z &=& 3
\end{syslineq}

\end{document}

output

事実上,array 環境。& を並べるのが鬱陶しい…。

systeme パッケージ

CTAN: Package systeme - Format systems of equations (連立方程式の整形)

  • TeX Live や MiKTeX には含まれている。
  • 自分のシステムに新たに追加する場合は,systeme.stysysteme.tex をダウンロードして,適当なところに置けばよい。
  • 説明書は仏語。でも,眺めていれば使い方は何となくわかる。たぶん。
example.tex
\documentclass{jsarticle}
\usepackage{systeme}

\begin{document}
\systeme{7x-y=1,y+z=2,-x+8z=3}
\end{document}

20170327-000001.png

\systeme の中は数式モードなので,中のものを $ でくくる必要はない,とのことらしい。

いろいろな使用例を掲載した頁を作ろう。>自分

autoaligne パッケージ

CTAN: Package autoaligne - Align terms and members in math expressions (項を揃えてくれる)

  • TeX Live や MiKTeX には含まれている。
  • 自分のシステムに新たに追加する場合は,autoaligne.styautoaligne.tex をダウンロードして,適当なところに置けばよい。
  • listofitems パッケージが必要。autoaligne パッケージを読み込む中で読み込まれる。
    • listofitems パッケージを自分のシステムに新たに追加する場合は,listofitems.stylistofitems.tex をダウンロードして,適当なところに置けばよい。
  • 説明書は仏語。でも,眺めていれば使い方は何となくわかる。たぶん。
  • \autoaligne の中は数式モードなので,中のものを $ でくくる必要はない,とのことらしい。
example.tex
\documentclass{jsarticle}
\usepackage{autoaligne}

\begin{document}
\autoaligne{7x-y=1\\y+z=2\\-x+8z=3}
\end{document}

output

あれれ? 期待通りに縦に揃ってくれない…。

縦に揃えるには,空くところに + を入れれば良いようだ。

example.tex
\documentclass{jsarticle}
\usepackage{autoaligne}

\begin{document}
\autoaligne{7x-y=1\\+y+z=2\\-x++8z=3}
\end{document}

output

いろいろな使用例を掲載した頁を作ろう。>自分

spalignパッケージ

CTAN: Package spalign - Type­set ma­tri­ces and ar­rays with spaces and semi­colons as de­lim­iters (行列の組版,成分の区切りはスペースとセミコロン)

  • TeX Live や MiKTeX には含まれている。
  • 自分のシステムに新たに追加する場合は,spalign.dtxspalign.ins をダウンロードして,platex spalign.ins を実行して,得られた spalign.sty を適当なところに置けばよい。

\spalignsys コマンドの利用。\+ は2項演算子のダミー。\. はダミー項。

exapmle.tex
\documentclass{jsarticle}
\usepackage{spalign}

\begin{document}

$\spalignsys{7x - y \+ \. = 1; \. \+ y + z = 2; -x \+ \. + 8z = 3}$
\qquad
$\left\{\spalignsys*{
  7x - y \+ \. = 1; \. \+ y + z = 2; -x \+ \. + 8z = 3
 }\right.$

\end{document}

output

半角スペースが区切りと認識されることに注意。係数と文字の間にうっかり空白を入れると…,

exapmle.tex
\documentclass{jsarticle}
\usepackage{spalign}

\begin{document}

$\spalignsys{7 x - y \+ \. = 1; \. \+ y + z = 2; -x \+ \. + 8 z = 3}$

\end{document}

output

…こんな風に失敗する。

いろいろな使用例を掲載した頁を作ろう。>自分

参考


おしまい。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1