0

I want to highlight a specific row using the row number in csvsimple-l3 but I don't know how. For example, I need to bold the 4th row but I don't want to add

row{4} = {font=\bfseries}

to mycsvstyle because I will use this style for other tables. How can I define a macro to set the style for a row that I want using the row number?

\documentclass[12pt]{article}

\usepackage{tabularray} \usepackage{xcolor} \usepackage{pgfplotstable} \usepackage{csvsimple-l3}

\begin{filecontents}{report.csv} "PRODUCT_CODE","PRODUCT_NAME","LIST_PRICE","DISCOUNT_PERCENT" "sg","Gibson SG","2517","52" "fg700s","Yamaha FG700S","489.99","39" "rodriguez","Rodriguez Caballero 11","415","38" "strat","Fender Stratocaster","699","30" "les_paul","Gibson Les Paul","1299","30" "ludwig","Ludwig 5-piece Drum Set with Cymbals","699.99","30" "precision","Fender Precision","799.99","30" "hofner","Hofner Icon","499.99","25" "tama","Tama 5-Piece Drum Set with Cymbals","799.99","15" "washburn","Washburn D10S","299","0" \end{filecontents}

\definecolor{codebgtable}{HTML}{F2F2F2}

\csvstyle{mycsvstyle}{ respect underscore, before reading={\catcode\"=9}, after reading={\catcode"=13}, no head, tabularray = { rowsep=5pt,colsep=9pt, stretch=1.3, %hlines, vlines, row{odd} = {codebgtable}, row{1} = {codebgtable, font=\bfseries, halign = c}, }, table head = {\hline}, table foot = {\hline}, late after first line = {\\hline}, }

\begin{document}

\begin{table}[h!] \centering \resizebox{1.\textwidth}{!}{ \csvreader[mycsvstyle]{report.csv}{ %if \thecsvrow = 4 \setrow{\bfseries} }{ \csvlinetotablerow } } \end{table}

\end{document}

qqv dao
  • 33
  • 1
    a track: row{#1}={font=\bfseries} and \csvreader[mycsvstyle=4]{report.csv}{... But to improve. Doesn't work without arguments. – pascal974 Feb 07 '23 at 11:55
  • work with \csvreader[mycsvstyle=0]{report.csv}{ but not very nice – pascal974 Feb 07 '23 at 11:57
  • 1
    Unrelated, \resizebox doesn't seem like a good idea. see this post https://tex.stackexchange.com/questions/425453/why-not-scale-elements-that-contain-text and https://tex.stackexchange.com/questions/666900/using-adjustbox-withouth -changing-fontsize/674267#674267 – pascal974 Feb 07 '23 at 13:13

0 Answers0