2

I have a xtable generated in R/Sweave that I would like displayed in portrait mode in a pdf. The spaces in the spacedSeq should properly align the sequences.

How can I force this to be in a monospace font. I can use XeteX if necessary but I don't know what fonts are available to me from my TeXlive installation on OS X.

a subset of the table below:

% latex table generated in R 2.13.0 by xtable 1.5-6 package
% Tue Nov  1 13:53:39 2011
\begin{table}[ht]
\begin{center}
\begin{tabular}{rlllrrrrrr}
  \hline
 & rname & spacedSeq & edits & RB494N & RB494T & RB495N & RB495T & RB498N & RB498T \\ 
  \hline
1 & hsa-let-7a-1 &      AGAGGTAGTAGGTTGTATAA & 6:T 25:G &   1 &   0 &   0 &   0 &   0 &   0 \\ 
  2 & hsa-let-7a-1 &      AGAGGTAGTAGGTTGTATAGT & 6:T &   7 &   5 &  21 &   4 &   5 &   2 \\ 
  3 & hsa-let-7a-1 &      AGAGGTAGTAGGTTGTATAGTT & 6:T &  14 &  16 & 113 &  20 &  30 &   4 \\ 
  4 & hsa-let-7a-1 &      AGAGGTAGTAGGTTGTATAGTTA & 6:T 28:T &   2 &   1 &   8 &   0 &   0 &   0 \\ 
  5 & hsa-let-7a-1 &      AGAGGTAGTAGGTTGTATAGTTG & 6:T 28:T &   1 &   0 &   1 &   1 &   1 &   0 \\ 
  6 & hsa-let-7a-1 &      AGAGGTAGTAGGTTGTATAGTTGT & 6:T 28:T &   1 &   0 &   0 &   0 &   0 &   0 \\ 
  7 & hsa-let-7a-1 &      AGATGTAGTAGGTTGTATAGT & 6:T 9:G &   1 &   0 &   2 &   0 &   0 &   0 \\ 
  8 & hsa-let-7a-1 &        AGGTAGTAGGTTGTATAGT &  &   5 &   0 &   0 &   0 &   8 &   1 \\ 
  9 & hsa-let-7a-1 &        AGGTAGTAGGTTGTATAGTTT &  &   1 &   0 &   0 &   0 &   0 &   0 \\ 
  10 & hsa-let-7a-1 &        AGGTAGTGGGTTGTATAGT & 15:A &   1 &   0 &   0 &   0 &   0 &   0 \\ 
   \hline
\end{tabular}
\end{center}
\end{table}
1
  • Welcome to TeX.sx! Not sure if I understand you correct. The normal way to make unbreakable spaces (in any font) is to use ~.
    – Martin Scharrer
    Nov 1 '11 at 18:15
2

This requires the array package:

\usepackage{array}

Then you can use the >{...} syntax for adding declarations for one column; spaces not to be ignored are obtained by ~

\begin{tabular}{rl>{\ttfamily}llrrrrrr}
  \hline
 & rname & \normalfont spacedSeq & edits & RB494N & RB494T & RB495N & RB495T & RB498N & RB498T \\
  \hline
 1 & hsa-let-7a-1 & AGAGGTAGTAGGTTGTATAA & 6:T 25:G &   1 &   0 &   0 &   0 &   0 &   0 \\
 2 & hsa-let-7a-1 & AGAGGTAGTAGGTTGTATAGT & 6:T &   7 &   5 &  21 &   4 &   5 &   2 \\
 3 & hsa-let-7a-1 & AGAGGTAGTAGGTTGTATAGTT & 6:T &  14 &  16 & 113 &  20 &  30 &   4 \\
 4 & hsa-let-7a-1 & AGAGGTAGTAGGTTGTATAGTTA & 6:T 28:T &   2 &   1 &   8 &   0 &   0 &   0 \\
 5 & hsa-let-7a-1 & AGAGGTAGTAGGTTGTATAGTTG & 6:T 28:T &   1 &   0 &   1 &   1 &   1 &   0 \\
 6 & hsa-let-7a-1 & AGAGGTAGTAGGTTGTATAGTTGT & 6:T 28:T &   1 &   0 &   0 &   0 &   0 &   0 \\
 7 & hsa-let-7a-1 & AGATGTAGTAGGTTGTATAGT & 6:T 9:G &   1 &   0 &   2 &   0 &   0 &   0 \\
 8 & hsa-let-7a-1 & ~~AGGTAGTAGGTTGTATAGT &  &   5 &   0 &   0 &   0 &   8 &   1 \\
 9 & hsa-let-7a-1 & ~~AGGTAGTAGGTTGTATAGTTT &  &   1 &   0 &   0 &   0 &   0 &   0 \\
10 & hsa-let-7a-1 & ~~AGGTAGTGGGTTGTATAGT & 15:A &   1 &   0 &   0 &   0 &   0 &   0 \\
\hline
\end{tabular}

One has to override the \ttfamily declaration in the header, which can be done by

\normalfont spacedSeq

or

\multicolumn{1}{l}{spacedSeq}
1
  • You may want to have the heading spacedSeq non-monospaced. The additional column declaration can be overridden using \multicolumn{1}{l}{spacedSeq}.
    – Werner
    Nov 1 '11 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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