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 latex table in which I have entered some data that I want to share with another party. I have entered data with values that I think the parameters should take. I want to keep those values available as a reference. However I want to send the table (in pdf format) without the values visible so that the other party can input/share their values. How can I delete the values of a certain column except for the column header? Here is an example of the table:

\begin{tabular}{|r|c|c|}\hline
Parameter & Symbol & Value\\\hline\hline
Saturation Magnetization & $M_s$ & 100 emu/cc\\
\sd & $\sigma_{Ms}$ & 5\%\\\hline
Anisotropy & $H_k$ & 8kOe\\
\sd & $\sigma_{Hk}$ & 5\%\\\hline
Coercive field & $H_c$ & \\\hline
Exchange coupling & $A_x$ & 2.5e-9 erg/cm\\
\sd & $\sigma_{Ax}$ & 5\%\\\hline
\end{tabular}

I wish to keep the actual values in the latex file, but blank out the values in the pdf file to share with the other party, while the column header ("Value" in this case) is not blanked out. It would be nice if with a little switch we can turn the values on and off in the pdf file. Is there a way to do that?

Thanks.

share|improve this question
    
You can use \phantom{<value>} –  Harish Kumar Jul 4 at 1:23

3 Answers 3

All is done by changing the meaning of macro \1:

\documentclass{article}

\begin{document}

A version for 3 columns, \verb+\sd+ changed to sd.

\def\1#1&#2&#3\\{ #1& #2&\\}

Without values in 3rd column

\begin{tabular}{|r|c|c|}\hline
Parameter & Symbol & Value\\\hline\hline
\1Saturation Magnetization & $M_s$ & 100 emu/cc\\
\1 sd & $\sigma_{Ms}$ & 5\%\\\hline
\1Anisotropy & $H_k$ & 8kOe\\
\1 sd & $\sigma_{Hk}$ & 5\%\\\hline
Coercive field & $H_c$ & \\\hline
\1Exchange coupling & $A_x$ & 2.5e-9 erg/cm\\
\1 sd & $\sigma_{Ax}$ & 5\%\\\hline
\end{tabular}

\def\1#1&#2&#3\\{ #1& #2&#3\\}

With values in 3rd column

\begin{tabular}{|r|c|c|}\hline
Parameter & Symbol & Value\\\hline\hline
\1Saturation Magnetization & $M_s$ & 100 emu/cc\\
\1 sd & $\sigma_{Ms}$ & 5\%\\\hline
\1Anisotropy & $H_k$ & 8kOe\\
\1 sd & $\sigma_{Hk}$ & 5\%\\\hline
Coercive field & $H_c$ & \\\hline
\1Exchange coupling & $A_x$ & 2.5e-9 erg/cm\\
\1 sd & $\sigma_{Ax}$ & 5\%\\\hline
\end{tabular}


\end{document}

enter image description here

share|improve this answer

You can collect the cell contents and manipulate it with the aid of collcell. Below I've defined two column types: g and G{<len>}. The g-column gobbles its argument (eats it up and does nothing with it), while the G{<len>} column does the same but inserts a space of length <len> in the cell instead.

enter image description here

\documentclass{article}
\usepackage{collcell,booktabs}
\makeatletter
\newcolumntype{g}{>{\collectcell\@gobble}c<{\endcollectcell}}
\newlength{\fixedwidth}
\newcommand{\fwidth}[1]{\hspace*{\fixedwidth}}
\newcolumntype{G}[1]{>{\setlength{\fixedwidth}{#1}\collectcell\fwidth}c<{\endcollectcell}}
\makeatother
\setlength{\parindent}{0pt}% Just for this example
\begin{document}

Using column type \verb|c|:

\begin{tabular}{r c c}
  \toprule
  \textbf{Parameter} & \textbf{Symbol} & \textbf{Value} \\
  \midrule
  Saturation Magnetization & $M_s$         & 100 emu/cc \\
  sd                       & $\sigma_{Ms}$ & 5\% \\
  Anisotropy               & $H_k$         & 8kOe \\
  sd                       & $\sigma_{Hk}$ & 5\% \\
  Coercive field           & $H_c$         & \\
  Exchange coupling        & $A_x$         & 2.5e-9 erg/cm \\
  sd                       & $\sigma_{Ax}$ & 5\% \\
  \bottomrule
\end{tabular}

\bigskip

Using column type \verb|g|:

\begin{tabular}{r c g}
  \toprule
  \textbf{Parameter} & \textbf{Symbol} & \multicolumn{1}{c}{\textbf{Value}} \\
  \midrule
  Saturation Magnetization & $M_s$         & 100 emu/cc \\
  sd                       & $\sigma_{Ms}$ & 5\% \\
  Anisotropy               & $H_k$         & 8kOe \\
  sd                       & $\sigma_{Hk}$ & 5\% \\
  Coercive field           & $H_c$         & \\
  Exchange coupling        & $A_x$         & 2.5e-9 erg/cm \\
  sd                       & $\sigma_{Ax}$ & 5\% \\
  \bottomrule
\end{tabular}

\bigskip

Using column type \verb|G|:

\begin{tabular}{r c G{75pt}}
  \toprule
  \textbf{Parameter} & \textbf{Symbol} & \multicolumn{1}{c}{\textbf{Value}} \\
  \midrule
  Saturation Magnetization & $M_s$         & 100 emu/cc \\
  sd                       & $\sigma_{Ms}$ & 5\% \\
  Anisotropy               & $H_k$         & 8kOe \\
  sd                       & $\sigma_{Hk}$ & 5\% \\
  Coercive field           & $H_c$         & \\
  Exchange coupling        & $A_x$         & 2.5e-9 erg/cm \\
  sd                       & $\sigma_{Ax}$ & 5\% \\
  \bottomrule
\end{tabular}
\end{document}

G-column cells pass their entries to \fwidth which takes an argument but does nothing with it (...similar to \@gobble).

Note that the column heading is set using \multicolumn{1}{c}{..}. This is meant to override the column set in the tabular column specification, so that it isn't gobbled itself.

If you wish to delete the entire column you can use a similar method (also discussed in Easiest way to delete a column?).

share|improve this answer

My solution is this: To color with white color the columns that you wish to hide. For that i use the array package that allows define a new type of column with the \newcolumntype{h}{>{\color{white}}c} and the header row i color it with black.

This allows hide a column simply changing the c (or l or r) column specification by h (hidden).

My code with the column 2 hidden is

\documentclass{article}
\usepackage{array}
\usepackage{xcolor}
\newcolumntype{h}{>{\color{white}}c} % type 'h' = hidden
\begin{document}
\begin{tabular}{|r|h|c|}\hline
   \color{black}Parameter & \color{black}Symbol & \color{black}Value\\\hline\hline
   Saturation Magnetization & $M_s$ & 100 emu/cc\\
   sd & $\sigma_{Ms}$ & 5\%\\\hline
   Anisotropy & $H_k$ & 8kOe\\
   sd & $\sigma_{Hk}$ & 5\%\\\hline
   Coercive field & $H_c$ & \\\hline
   Exchange coupling & $A_x$ & 2.5e-9 erg/cm\\
   sd & $\sigma_{Ax}$ & 5\%\\\hline
\end{tabular}
\end{document}

this produces

enter image description here

This also preserves the column space. If you want to hide the column 3 instead of 2 simply change \begin{tabular}{|r|h|c|} by \begin{tabular}{|r|c|h|}.

This is the closest thing to a switch that I could achieve.

share|improve this answer
    
But when sent as PDF, the information is is the table and can easily been retrived. Just copy and paste, or open the pdf in an text editor. –  Sveinung Jul 4 at 7:47

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.