TransWikia.com

Change behaviour of a custom command

TeX - LaTeX Asked by agarg on February 23, 2021

I have a custom command to itemize:

newcommand{CVItem}[1]{
    itemsmall{#1vspace{-2pt}}
}

How can I customize this command to change the label/ bullet type, say asterisk/ dash in different cases. Is it possible to pass the label type as the argument?

And if I have a given label type in the surrounding itemize command, which is again a custom one like the one below,can I change the bullet/ label type.

newcommand{CVItemListStart}{begin{itemize}[label=$bullet$]}
    newcommand{CVItemListEnd}{end{itemize}vspace{2pt}}

2 Answers

I don't think that you need to define a new command. The following code will do the job.

begin{itemize}
    item [$ast$] Point 1
    item [$bullet$] Point 2
end{itemize}

Write the symbol you want to use for label/bullet type in square brackets after item. It will do the job.

Answered by Santosh Fatale on February 23, 2021

You can make your list-like construction CVItemListStart...CVItemListEnd act like enumitem's label-controlled environment in the following way:

enter image description here

documentclass{article}

usepackage{enumitem}

newcommand{CVItem}[2][defaultbullet]{%
  item[#1] {small #2par}
}

newcommand{defaultbullet}{textbullet}
newcommand{CVItemListStart}[1][textbullet]{%
  begingroup
  renewcommand{defaultbullet}{#1}%
  begin{itemize}[label=#1]}
newcommand{CVItemListEnd}{%
  end{itemize}
  endgroup
}

begin{document}

First list:
CVItemListStart
  CVItem{First}
  CVItem[$ast$]{Second}
  CVItem{Third}
  CVItem[--]{Final}
CVItemListEnd

Second list:
CVItemListStart[$ast$]
  CVItem{First}
  CVItem{Second}
  CVItem{Third}
  CVItem{Final}
CVItemListEnd

Third list:
CVItemListStart
  CVItem{First}
  CVItem{Second}
  CVItem{Third}
  CVItem{Final}
CVItemListEnd

end{document}

Answered by Werner on February 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP