
私は定積分専用のショートカットを作成しました。しかし、メッセージ ログには間違い (エラー) があったと表示されています。その理由を教えていただき、\newcommand
特に定積分に関して、よりよいコードの設計を手伝っていただけませんか?
私が試したコードは次のとおりです:
\newcommand{\intl}[3][]{\displaystyle{\int_{#1}^{#2} {#3}\,\,dd x}}
ああ、これは\dd
の略です\mathrm{d}
。そしては{#3}
、私が統合したい機能を意味します。
編集はここから始まる(アドバイスをくれた @Andrew に感謝します) -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
これが私のサンプルです:
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\newcommand{\dd}{\mathrm{d}} % <--- Editted here
\newcommand{\intl}[3][]{\displaystyle{\int_{#1}^{#2} {#3}\,\,dd x}}
\begin{document}
$$\intl{1}{5}{x}$$
\\
This is hoped to be like this,
$$\displaystyle\int_{1}^{5}x\dd x$$ % <--- Editted here
\end{document}
答え1
これを試してみてください。($$..$$ は LaTeX 文書では使用しないでください。\displaystyle は \[..\] 環境内ではデフォルトです)
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\newcommand{\dd}{\mathrm{d}}
\newcommand{\intl}[3]{\displaystyle\int^{#2}_{#1}{#3}\,\dd x}
\begin{document}
\[\intl{1}{5}{x}\]
\\
This is hoped to be like this,
\[\int_{1}^{5}x\dd x\]
\end{document}