1
\begin{itemize}
\item[Key point 1] 
\item[Key point 2]  
\end{itemize}

I want to change the bullets in "itemize" to other labels. The above works but the problem is that "Key point 1" and "Key point 2" now stretch beyond the left border of the page, so I need to add horizontal space to bring it back to the normal position. I cannot just add \hspace before \item. How can I do it?

  • A tabular would be a better option for such case... Dont you think so? – koleygr Oct 19 '17 at 9:00
  • If it's possible with itemize, I'd like to use itemize. – Karo Oct 19 '17 at 9:04
  • 1
    Ok... but then \item[Key 1] and \item[Key 10] will need separate space to added? Or you want them aligned right? (with tabular any of this would be really easy) – koleygr Oct 19 '17 at 9:10
  • Fortunately I won't have up to 10, so this is not a worry – Karo Oct 19 '17 at 9:39
  • Are you looking for the description environment? – Andrew Swann Oct 19 '17 at 14:33
7

A simple solution with the parameters of enumitem:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{calc}
\usepackage{enumitem}

\begin{document}

text\vspace{10pt}
\begin{itemize}[wide =0pt, labelwidth=\widthof{Key point 10}]
\item[Key point 1] Optional item here
\item[Key point 10] Another item
\end{itemize}

text

\end{document} 

enter image description here

  • 1
    Your code is exactly the same as koleygr's, is that a copy-paste mistake? – Torbjørn T. Oct 19 '17 at 17:55
  • 3
    @TorbjørnT.: Oops! A problem with my clipboard manager. Indeed I copied koleygr's code to avoid having to type a full code, and replaced his specific code by mine. It's fixed. Thanks for pointing the problem! – Bernard Oct 19 '17 at 18:14
  • +1 after the real code :P... I Didn't used calc package and tried to align too,but the options you used are really helpful for me. I will leave my answer just as an alternative with boxes. – koleygr Oct 19 '17 at 18:29
  • @koleygr: Thanks! Your answer is fine too. I think we proceed differently: personally I favour using existing packages, patching them if necessary, as the authors are much more experienced than I am in low-level programming. – Bernard Oct 19 '17 at 18:37
4

Here is a solution:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\newlength{\mylength}
\newsavebox{\mybox}

\def\FindLength#1{%
\savebox{\mybox}{\hbox{#1}}%
\setlength{\mylength}{\wd\mybox}%
}%

\newenvironment{myitemize}[1]{%
\FindLength{#1}%
\begin{itemize}[leftmargin=19pt]
\setlength{\itemindent}{\mylength}%
}{%
\end{itemize}%
}

\begin{document}
text\vspace{10pt}

\begin{myitemize}{Key point 10}
\item[Key point 1] Optional item here
\item[Key point 10]   Another item
\end{myitemize}


text


\end{document}

I am sure there are better solutions, but it works with different lengths too, like "key point 2" and "key point 102"...

I don't know to explain the "leftmargin =19pt" but may be someone will help or I will find it later... (I found it through tests, and may be need to be changed according to your document class).

If you want any explanation just ask.

Here is the output:

enter image description here

and with same lengths:

enter image description here

  • 1
    why have you got \hbox here \savebox{\mybox}{\hbox{#1}}% ? but you do not need \savebox at all, you can replace \FindLength by \settowidth\itemindent{#1}. \settowidth is defined in the format it doesn't need a package – David Carlisle Oct 19 '17 at 21:48
  • Thanks @DavidCarlisle... I will take a look. I knew \settowidth but was using this with \usebox{\mybox} because usually I measure heights... And so I am just used to it. I didn't knew itemindent and I will take a look very soon. Thanks again – koleygr Oct 19 '17 at 21:55
  • there is a settoheight as well:-) – David Carlisle Oct 19 '17 at 21:58
  • yes... and \settototalheight but with calc. The point there is that you need a box to measure the height. (At least I do) And thus I am used to the same way for widths too (And didn't knew the itemindent as an alternative) – koleygr Oct 19 '17 at 22:23
  • no settoheight and settodepth are defined in the format as well as settowidth. I'm not sure what you mean by not knowing \itemindent I just took that example from your answer. and with \setbox you shouldn't use \hbox was the point of my initial comment – David Carlisle Oct 19 '17 at 23:18

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.