I have a situation here. I am designing an IPA Vowel Chart and I have created a new font environment for the IPA characters using the IPA font Doulos SIL like this: \newfontfamily{\ipafont}{Doulos SIL}
Now I would like to use this command in the title to write "IPA" phonetically in the IPA alphabet inside of \NewEnviron{heading} using the environ package (found just before \begin{document}).
Problem Upon adding the \ipafont{} command to a line, instead of the brackets containing the font to be changed, the command simply applies itself to the rest of the line, messing up my nice title. See the code and picture below:
%%% -*- mode:latex; mode:font-lock; -*-
\documentclass[12pt,a4paper]{article}
\usepackage{fontspec}
\usepackage{geometry}
%HEADER FOOTER
\usepackage{fancyhdr}
\lhead{\textsc{Sounds in American English}} \chead{\textsc{}} \rhead{\textsc{}
\lfoot{\textsc{created on \today \space \currenttime}} \cfoot{\textsc{}}} \rfoot{\textsc{-\thepage-}}
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\pagestyle{fancy}%ADD HEADER FOOTER TO PAGE EXCEPT TITLE PAGE
%USE THISPAGESTYLE{EMPTY} BELOW MAKETITLE OR {FANCY}
\usepackage{datetime}
\usepackage{vowel}
\usepackage{soul} % use this (many fancier options)
\usepackage{tabularx}
\usepackage{pdflscape}
%\setmainfont{Doulos SIL}
\newfontfamily{\ipafont}{Doulos SIL}%ADD FONT IN PREAMBLE, USAGE IN BODY: \otherfont{some text}
%OR {\fontspec{Zapfino} different text} IN BODY FOR ONE-TIME USE
%HIGHLIGHTER CODE
\usepackage{tikz}
\usepackage{amsmath}
\makeatletter
\newenvironment{btHighlight}[1][]
{\begingroup\tikzset{bt@Highlight@par/.style={#1}}\begin{lrbox}{\@tempboxa}}
{\end{lrbox}\bt@HL@box[bt@Highlight@par]{\@tempboxa}\endgroup}
\newcommand\btHL[1][]{%
\begin{btHighlight}[#1]\bgroup\aftergroup\bt@HL@endenv%
}
\def\bt@HL@endenv{%
\end{btHighlight}%
\egroup
}
\newcommand{\bt@HL@box}[2][]{%
\tikz[#1]{%
\pgfpathrectangle{\pgfpoint{0pt}{0pt}}{\pgfpoint{\wd #2}{\ht #2}}%
\pgfusepath{use as bounding box}%
\node[anchor=base west, fill=orange!30,outer sep=0pt,inner xsep=0.2em, inner ysep=0.1em, #1]{\usebox{#2}};
}%
}
\makeatother
\newcommand{\tikzhighlight}[2][red]{%
{\btHL[fill=#1!10,draw=#1,rounded corners]#2}%
}
\newcommand{\BlankCell}{}
\newcommand{\ex}[1]{\small{\tikzhighlight[blue]{#1}\hspace{.5em}}}
\newcommand{\oex}[1]{\small{\tikzhighlight[yellow]{#1}\hspace{.5em}}}
\newcommand{\vl}[1]{\Large{[\ipafont{#1}}]}
\usepackage{tikz}
\usetikzlibrary{calendar,shapes,backgrounds}
\usepackage{environ}
\NewEnviron{heading}{\begin{figure}[h!]\centering\begin{tikzpicture}[align=center,background rectangle/.style={fill=white!05},framed]\node {\BODY};\end{tikzpicture}\end{figure}}
\begin{document}
%\maketitle
\thispagestyle{fancy}
% \nopagebreak[4]
\begin{landscape}
\begin{heading}
\Large IPA [\ipafont{aɪ pʰiː eɪ}] Vowel Chart for\\\Large Californian English
\end{heading}
\begin{center}
{\vowelhunit=8.5em
\begin{vowel}
%\putcvowel[l]{i}{1}
\putvowel[l]{\vl{i} \ex{b\textbf{ea}d}}{0pt}{0pt}
\putcvowel[r]{\vl{y} \ex{\st{f\textbf{üh}len}}}{1}
\putcvowel[l]{\vl{e} \ex{b\textbf{ay}ed}}{2}
\putcvowel[r]{\vl{ø} *}{2}
\putcvowel[l]{\vl{ɛ} \ex{b\textbf{e}t,b\textbf{e}d}}{3}
\putcvowel[r]{\vl{œ} *}{3}
\putcvowel[l]{\vl{a} *}{4}
\putcvowel[r]{\vl{ɶ} *}{4}
\putcvowel[l]{\vl{ɑ} \ex{p\textbf{o}d}}{5}
\putcvowel[r]{\vl{ɒ} *}{5}
\putcvowel[l]{\vl{ʌ} \ex{b\textbf{u}d}}{6}
\putcvowel[r]{\vl{ᴐ} \ex{b\textbf{o}y (diphthong)}}{6}
\putcvowel[l]{\vl{ɤ} *}{7}
\putcvowel[r]{\vl{}o \ex{b\textbf{o}de}}{7}
\putcvowel[l]{\vl{ɯ} *}{8}
\putcvowel[r]{\vl{u} \ex{b\textbf{oo}ed}}{8}
\putcvowel[l]{\vl{ɨ} *}{9}
\putcvowel[r]{\vl{ʉ} *}{9}
\putcvowel[l]{\vl{ɘ} *}{10}
\putcvowel[r]{\vl{ɵ} *}{10}
\putcvowel{\vl{ə} \ex{\textbf{a}bout,\textbf{a}bove}}{11}
\putcvowel[l]{\vl{ɜ} \oex{b\textbf{u}st} *}{12}
\putcvowel[r]{\vl{ɞ} *}{12}
\putcvowel[l]{\vl{I} \ex{b\textbf{i}d}}{13}
\putcvowel[r]{\vl{Y} *}{13}
\putcvowel{\vl{ʊ} \ex{g\textbf{oo}d}}{14}
\putcvowel{\vl{ɐ} *}{15}
\putcvowel{\vl{æ} \ex{b\textbf{a}d}}{16}
\end{vowel}
}%
\end{center}
\tikzhighlight[blue]{CA English} \hspace{.5em}\tikzhighlight[green]{OH English}
\end{landscape}
\section*{Vowels}
\begin{tabularx}{\textwidth}{l}
/i/ as in seat \\
/ɪ/ as in sit \\
/eɪ/ as in cake \\
/ɛ/ as in met \\
/æ/ as in cat \\
/ɑ/ as in father \\
/ə/ as in bun \\
/ɔ/ as in law \\
/oʊ/ as in boat \\
/ʊ/ as in wood \\
/u/ as in two \\
/ər/ as in heard \\
/aɪ/ as in mine \\
/aʊ/ as in mouse \\
/ɔɪ/ as in boy \\
\end{tabularx}
\end{document}


\small,\Largeand\ipafontare not commands with an argument, but declarations: so{\ipafont #1}, for example, not\ipafont{#1}. The same for\smalland\Large– egreg Sep 6 '12 at 19:14{\ipafont aɪ pʰiː eɪ}. Curly braces limit scope, brackets do not. I'd also advise to slip a\parsomewhere in the node, because your use of\Largemesses up the like skip, but I don't know where it is allowed... – Stephan Lehmke Sep 6 '12 at 19:55