Math & Sciencevector as argument to function

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

vector as argument to function

Post by juliette »

I'd like to be able to write f([a b]) , except with the vector [a b] as a column vector rather than a row vector.

Further, I would like this to be in the middle of a plain sentence of words (not as part of an equation environment), as in:

"Functions like f([a b]) are interesting because...."

I've tried:

Code: Select all

$f(\left[ \right.$\begin{tabular}{c}$a$\\$b$\end{tabular} $\left. \right])$
My problem is that the a and b take up a lot more vertical space than I would like, and making them \tiny{} only makes the letters small, while the overall vector takes about the same amount of vertical space.

Is there a neater way of doing this ??

Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

vector as argument to function

Post by frabjous »

Do either of these strike your fancy?

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}
Functions like $f(\left[{a \atop b}\right])$ are interesting because \ldots

\bigskip
Functions like $f(\begin{bmatrix}a \\ b\end{bmatrix})$ are interesting because \ldots

\end{document}
(the bmatrix environment requires amsmath)
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

vector as argument to function

Post by gmedina »

For in-line expressions I would rather use the smallmatrix environment:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\newcommand\fvec[3][f]{%
  #1\big(\left[\begin{smallmatrix}#2 \\ #3\end{smallmatrix}\right]\big)}

\begin{document}

text text $\fvec{a}{b}$  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text 
 
text text $\fvec[h]{c}{d}$  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text 

\end{document}
frabjous wrote: ...$f(\left[{a \atop b}\right])$...
The amsmath package will issue the following warning

Code: Select all

Package amsmath Warning: Foreign command \atop;
(amsmath)                \frac or \genfrac should be used instead
(amsmath)                 on input line 13. warning when using \atop
to remind you that the TeX \atop command should not be used any longer in the body of a standard document (a similar situation occurs with \over).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

vector as argument to function

Post by localghost »

Although there is only an in-line version requested, here's a solution that also works in displayed math environments.

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\newcommand{\fvec}[3][f]{#1\left(\genfrac{[}{]}{0pt}{}{#2}{#3}\right)}

\begin{document}
  With \( \fvec{a}{b} \) you have the in-line version of the math expression.

  With
  \[
    \fvec[h]{c}{d}
  \]
  you have the displayed version of the math expression.
\end{document}
Best regards
Thorsten
Post Reply