Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I copy a code from Maple and past it into LaTeX. For example, the equation of the line in geometry 3D is

\begin{equation*}
\begin{cases}
x =-1 + 5t,\\
y = 3+t,\\
z =-3 + t 
\end{cases}
\end{equation*}

The code in Maple is [-1+5*t, 3+t, -3+t].
I want to make a macro. How do I do that? I tried

\newcommand{\droit}[3]{\displaystyle\Delta: \begin{cases}
{#1},\\
{#2},\\
{#3}.
\end{cases}}            

\begin{equation*}
\droit{x =t + 1}{y = 2t - 2}{3t + 1}
\end{equation*}
share|improve this question
    
You tried? But what happened? And what did you expect? What should your new command do? What has that to do with Maple? Do you want a macro that works like \droit[x=t+1,y=2t-2,z=3t+1]? –  Qrrbrbirlbel Nov 28 '12 at 2:30

1 Answer 1

up vote 3 down vote accepted

Hopefully, this goes in the right direction …

Code

\documentclass{article}
\usepackage{amsmath}
\usepackage{xstring}
\newcommand{\substituteMe}[2]{\StrSubstitute{#1}{*}{#2}}
\def\droit[#1,#2,#3]{\Delta:\begin{cases}#1,\\#2,\\#3.\end{cases}}
\def\Droit[#1,#2,#3]{\Delta:\begin{cases}x=#1,\\y=#2,\\z=#3.\end{cases}}
\def\DRoit#1[#2,#3,#4]{\Delta:\begin{cases}x=\substituteMe{#2}{#1},\\y=\substituteMe{#3}{#1},\\z=\substituteMe{#4}{#1}.\end{cases}}
\begin{document}
\begin{equation*}
    \droit[x=t+1,y=2t-2,z=3t+1]
\end{equation*}
\begin{equation*}
    \Droit[t+1,2t-2,3t+1]
\end{equation*}
\begin{equation*}
    \DRoit[t+1,2*t-2,3*t+1]
\end{equation*}
\begin{equation*}
    \DRoit\cdot[t+1,2*t-2,3*t+1]
\end{equation*}
\end{document}

Output

enter image description here

share|improve this answer
    
I see a situation is the name of the line is not alway $\Delta$. Please help me at the command '\def\DRoit#1[#2,#3,#4]{\Delta:\begin{cases}x=\substituteMe{#2}{#1},\\y=\substitu‌​teMe{#3}{#1},\\z=\substituteMe{#4}{#1}.\end{cases}}'. –  minthao_2011 Nov 28 '12 at 6:33
    
@minthao_2011 You can remove \Delta: from the macro's definition or do you want to have \DRoit having a fifth argument that is then typeset in front of :\begin{cases}? –  Qrrbrbirlbel Nov 29 '12 at 11:11
    
Yes. I did so. Thank you very much. –  minthao_2011 Nov 29 '12 at 16:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.