如何将整行的透明度设置为0.5?

如何将整行的透明度设置为0.5?
\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage{pdflscape}
\usepackage{transparent}
\usepackage{iftex}
\usepackage{graphicx}
\usepackage[table]{xcolor}
\usepackage{makecell}
\usepackage{color}
\usepackage{ragged2e}
\usepackage[right=0.5in, left=0.5in, top=0.78in, bottom=0.5in]{geometry}

\makeatletter
\newcommand*{\@rowstyle}{}
\newcommand*{\rowstyle}[1]{% sets the style of the next row
  \gdef\@rowstyle{#1}%
  \@rowstyle\ignorespaces%
}

\newcolumntype{=}{% resets the row style
  >{\gdef\@rowstyle{}}%
}

\newcolumntype{+}{% adds the current row style to the next column
  >{\@rowstyle}%
}

\makeatother

\renewcommand{\arraystretch}{1.42}
\setlength{\arrayrulewidth}{0.25mm}
\arrayrulecolor{gray!40}
\begin{document}
\pagestyle{empty}
\begin{landscape}

\begin{table}
\centering
\scalebox{4}{
\begin{tabular}{|=c|+c|+c|+c|+c|+c|}
\rowcolor[gray]{0.65}\multicolumn{6}{c}{ \textcolor{white}{\scriptsize Meditation} \vspace*{0.2cm}}\\
\hline
\rowstyle{\color{gray}}
\rowstyle{\transparent{0.5}} 1 & 2 & 3 & 4 & 5 & 6\\ 
\hline
\rowstyle{\color{gray}}7 & 8 & 9 & 10 & 11 & 12 \\ 
\hline
\rowstyle{\color{gray}}13 & 14 & 15 & 16 & 17 & 18\\
\hline
\rowstyle{\color{gray}}19 & 20 & 21 & 22 & 23 & 24 \\ 
\hline
\rowstyle{\color{gray}}25 & 26 & 27 & 28 & 29 & 30\\ 
\hline
\end{tabular}}
\end{table}
\end{landscape}
\end{document}

答案1

由于您覆盖了内部定义,因此每行只能设置一个\rowstyle。因此您需要组合以下命令:\rowstyle{\color{gray}\transparent{0.5}}

\documentclass[12pt]{article}
\usepackage{transparent}
\usepackage[table]{xcolor}

\makeatletter
\newcommand*{\@rowstyle}{}
\newcommand*{\rowstyle}[1]{% sets the style of the next row
  \gdef\@rowstyle{#1}%
  \@rowstyle\ignorespaces%
}

\newcolumntype{=}{% resets the row style
  >{\gdef\@rowstyle{}}%
}

\newcolumntype{+}{% adds the current row style to the next column
  >{\@rowstyle}%
}

\makeatother

\renewcommand{\arraystretch}{1.42}
\setlength{\arrayrulewidth}{0.25mm}
\arrayrulecolor{gray!40}
\begin{document}
\begin{tabular}{|=c|+c|+c|+c|+c|+c|}
\rowcolor[gray]{0.65}\multicolumn{6}{c}{ \textcolor{white}{\scriptsize Meditation} \vspace*{0.2cm}}\\
\hline
\rowstyle{\color{gray}\transparent{0.5}}
 1 & 2 & 3 & 4 & 5 & 6\\ 
\hline
\rowstyle{\color{gray}}7 & 8 & 9 & 10 & 11 & 12 \\ 
\hline
\end{tabular}
\end{document}

在此处输入图片描述

相关内容