[Tex/LaTex] Helvetica neue for a table

fontstables

How can I set Helvetica Neue font (with a specified size and color – i.e. 9) for all the tables in my LaTeX file?

I'm trying with \fontfamily{helveticaneue}\selectfont but it doesn't work and honestly I don't have any idea about how to set it for all the tables in my paper.

This is an example of what I am doing; I would like to set "Helvetica neue, size 9" as the default font for all the tables:

\documentclass[a4paper,10pt]{article}
%\documentclass[a4paper,10pt]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{chngcntr}
\counterwithin{table}{section}
\usepackage{tabularx}

\title{Paper 1}

\begin{document}
\maketitle
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

\section{Dati}

\begin{table}[htb!]
\centering
\fontfamily{helvet}\selectfont
\begin{tabular}{L{2cm}|L{13cm}}  
    \hline
    \textbf{Variabili} & \textbf{Descrizione} \\
    \hline


gdp\_us & GDP USA trimestrale nominale (dal Q1 1947 al Q4 2013), fonte: FRED2\\  
    \hline
\end{tabular}
\caption{N/A}
\label{tab2.1}
\end{table}

\end{document}

Best Answer

Since you are using LaTeX or pdfLaTeX (and not LuaLaTeX or XeLaTeX), this is a little more involved.

I take it you want something like this:

Table set in Helvetica

Standard (pdf)LaTeX Solution

This is the solution I used to produce the output in the image above.

Comments in the code explain how to adjust various aspects of this to suit:

\documentclass[a4paper,10pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{chngcntr}
\counterwithin{table}{section}
\usepackage{tabularx}
\usepackage[T1]{fontenc}% T1 is a much better choice of encoding than the default

\makeatletter
  \def\Hv@scale{.95}% adjust to match the other fonts you are using
\makeatother
\DeclareRobustCommand{\tablefont}{%
        \fontencoding{\encodingdefault}%
        \fontseries{m}% change to mc for condensed - bold will not be condensed which is probably what you want; if you don't want LaTeX to change series, comment this line
        \fontshape{n}% upright - if you don't want LaTeX to change shape, comment this line
        \fontfamily{phv}% Note that 'helvet' is the name of the package but not the name of the font family. I found the correct value by looking in the package helvet.sty
        \fontsize{9}{12}% 9pt font with 12pt skip - adjust as desired
        \selectfont}
\DeclareTextFontCommand{\texttable}{\tablefont}% delete if you don't want this - it is analogous to \textit{} i.e. it takes an argument and typesets it in the font you are using for tables

\title{Paper 1}

\begin{document}
\maketitle
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

\section{Dati}

\begin{table}[htb!]
\centering
\tablefont% switch to the font you wish to use, as defined above
\begin{tabular}{L{2cm}|L{13cm}}
    \hline
    \textbf{Variabili} & \textbf{Descrizione} \\
    \hline


gdp\_us & GDP USA trimestrale nominale (dal Q1 1947 al Q4 2013), fonte: FRED2\\
    \hline
\end{tabular}
\caption{N/A}
\label{tab2.1}
\end{table}

\end{document}

Note that this solution uses a 'look-alike' substitute for Helvetica. I explained how to use the condensed version because I'm not sure if one might be closer to Helvetica Neue than the other. Moreover, there really is not one font called 'Helvetica' or 'Helvetical Neue'. There are many versions, look-alikes, not-so-look-alikes etc. Of course, you might want something like the original Helvetica but I'm guessing that's probably not what you have pictured.

This is the most straightforward solution if you want to stick to (pdf)LaTeX rather than switching to Lua/XeLaTeX.

Mac-Specific Solution

This uses the system-installed Helvetica Neue with generated support files for use with pdfLaTeX. Note that I do not know if the package I used to install this is still available. It also requires some configuration. However, it is really just a matter of following fairly simple instructions. In return, you get pdfLaTeX support for several OS X system fonts.

Note that this solution will not work with standard LaTeX. pdfLaTeX (or ConTeXt) is required. This is because the package does not require converting the fonts, which would give poorer results and probably violate the licence. However, it also means that you need truetype fonts. If your versions are opentype, you should use the XeLaTeX/LuaLaTeX solution Thruston is explaining as these will not work with pdfLaTeX.

\documentclass[a4paper,10pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{chngcntr}
\counterwithin{table}{section}
\usepackage{tabularx}
\usepackage[T1]{fontenc}

\usepackage[scale=.95]{gtamachelveticaneue}% adjust scaling to suit

\title{Paper 1}

\begin{document}
\maketitle
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

\section{Dati}

\begin{table}[htb!]
\centering
\sffamily\small% the package sets up the font as the default sans - if you don't want that, you can adapt the solution I posted above to use the files from this package but you would need to add the pdf map line from gtamachelveticaneue.sty; \small switches to 9pt as explained in Thruston's answer
\begin{tabular}{L{2cm}|L{13cm}}
    \hline
    \textbf{Variabili} & \textbf{Descrizione} \\
    \hline


gdp\_us & GDP USA trimestrale nominale (dal Q1 1947 al Q4 2013), fonte: FRED2\\
    \hline
\end{tabular}
\caption{N/A}
\label{tab2.1}
\end{table}

\end{document}

For comparison, this produces:

Table in Helvetica Neue

Note that this is the version of Helvetica Neue shipped with OS X 10.4 because that's the last version of OS X I used. So you might get slightly different (hopefully improved) results.

Related Question