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 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}

IPA Vowel Chart

share|improve this question
    
I don't see the messed up part in the picture. What is it? –  Stephan Lehmke Sep 6 '12 at 19:08
2  
\small, \Large and \ipafont are not commands with an argument, but declarations: so {\ipafont #1}, for example, not \ipafont{#1}. The same for \small and \Large –  egreg Sep 6 '12 at 19:14
    
The messed up part is in the title "Vowel Chart for" –  macmadness86 Sep 6 '12 at 19:26
    
Thanks egreg for the info. Could you please tell me how to isolate a declaration? –  macmadness86 Sep 6 '12 at 19:27
1  
As @egreg said: Use {\ipafont aɪ pʰiː eɪ}. Curly braces limit scope, brackets do not. I'd also advise to slip a \par somewhere in the node, because your use of \Large messes up the like skip, but I don't know where it is allowed... –  Stephan Lehmke Sep 6 '12 at 19:55
show 1 more comment

1 Answer

up vote 7 down vote accepted

Commands such as the standard \small and \Large, but also your font selection command \ipafont are not commands with an argument (similarly to \textbf, to make an example).

So your commands must be defined differently:

\newcommand{\ex}[1]{{\small\tikzhighlight[blue]{#1}}\hspace{.5em}}
\newcommand{\oex}[1]{{\small\tikzhighlight[yellow]{#1}}\hspace{.5em}}
\newcommand{\vl}[1]{{\Large[{\ipafont #1}]}}

In the last command, for instance, \vl{x} will be replaced by

{\Large[{\ipafont x}]}

where the outer pair of braces isolates the \Large declaration, the inner one isolates the \ipafont font selection. Thus x will be printed in "Large" size and Doulos SIL, while the brackets will be in the main document font.

The same for the code

\begin{heading}
\Large IPA [\ipafont{aɪ pʰiː eɪ}] Vowel Chart for\\\Large Californian English
\end{heading}

which should be

\begin{heading}
\Large IPA [{\ipafont aɪ pʰiː eɪ}] Vowel Chart for\\Californian English
\end{heading}

There's no need of braces to isolate \Large, because an environment forms a group that bounds the action of declarations.

If you prefer a command for selecting Doulos SIL like \textbf, then issue in your preamble the code

\DeclareTextFontCommand{\textipa}{\ipafont}

and then you'll be able to write

\textipa{aɪ pʰiː eɪ}

whence only the argument will be typeset in Doulos SIL with no leaking.

Actually, I don't see much sense in embedding the contents of heading as a single \node in a tikzpicture. Moreover, using a figure environment for it is surely wrong. Just say

\newenvironment{heading}
   {\begin{center}\Large}
   {\end{center}}

and now

\begin{heading}
IPA [{\ipafont aɪ pʰiː eɪ}] Vowel Chart for\\Californian English
\end{heading}

will give the correct result (with a correct distance between the two lines which is not obtained in a \node).

However, if you really need the tikzpicture and this is only a simplified version, don't use figure, but center.

share|improve this answer
    
I know that's not strictly what's asked, but maybe you could comment on the fact that \Large foo\\bar without a \par inside the same group is not a good idea? –  Stephan Lehmke Sep 6 '12 at 20:39
    
@StephanLehmke In this case it doesn't make any difference, as the text is passed on to \node. But your comment is quite useful. –  egreg Sep 6 '12 at 20:52
    
And does \node add a \par without wrapping the text in a group first? The two heading lines look awfully cramped on the example... –  Stephan Lehmke Sep 6 '12 at 20:54
    
@StephanLehmke Yes, they are wrong, but \node doesn't produce paragraphs, AFAIK. So adding \par doesn't help. I've added something to my answer. –  egreg Sep 6 '12 at 21:01
1  
@macmadness86 So probably a tabular inside heading is better to ensure correct spacing between lines. –  egreg Sep 8 '12 at 17:42
show 2 more comments

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.