2

When I add the fontspec package, the items in an itemize environment get an additional indention. You find the code in the following example, it is mainly from this question:

\documentclass{scrreprt}
\usepackage{blindtext, enumitem, fontspec}

\newcommand{\myicon}[1]{%
    \smash{%
        \raisebox{\dimexpr0.5\baselineskip-\height}{#1}%
    }
}

\setlist{nosep}

\begin{document}

\blindtext
\begin{itemize}[labelindent=4cm, leftmargin=*]
\item[\myicon{\rule{4cm}{4cm}}] \blindtext
\end{itemize}
\blindtext

\end{document}

enter image description here

The rule square does not align with the text.

When I remove the fontspec package the indention is correct: enter image description here

How is it possible to keep the correct indention with the `fontspec´ package?

3
  • 1
    I can't see your problem, but there is spurious space in your \myicon definition, and I would probably use [labelwidth=4cm, leftmargin=!,align=left] – Ulrike Fischer May 11 '15 at 16:12
  • I do not understand why I get an additional indention with the fontspec package. Where do I have the spurious space? I tried your option, unfortunately the rule jumps into the text. – Dirk May 11 '15 at 16:18
  • Your code works. I was to hectic and did not change the first option. – Dirk May 11 '15 at 19:48
1

The problem is probably in the different value of the em; but your way of setting the itemize is wrong:

\documentclass{scrreprt}
\usepackage{lipsum, enumitem,adjustbox}
\usepackage{fontspec}

\newcommand{\myicon}[1]{%
  \adjustbox{valign=t,set depth=0pt}{#1}%
}

\setlist{nosep}

\begin{document}

\lipsum[1]
\begin{itemize}[labelindent=-4cm, leftmargin=\dimexpr4cm+\labelsep]
\item[\myicon{\rule{4cm}{4cm}}] \lipsum[1]
\end{itemize}
\lipsum[1]

\end{document}

I used \adjustbox because it's easier.

The output with or without fontspec is the same.

enter image description here

7
  • We now have three possible options for the itemize environment. Which one is correct and why aren't the others? – Dirk May 11 '15 at 19:52
  • @Dirk There are several ways to do the same thing with enumitem. – egreg May 11 '15 at 19:57
  • I see. ;) Why do you think my way is wrong? – Dirk May 11 '15 at 20:16
  • @Dirk Because it doesn't work. ;-) – egreg May 11 '15 at 20:25
  • Good answer. :) One question: The top of the rule is a bit higher than the top of the corresponding textline "Lorem ipsum...". Is it possible to align this? – Dirk May 11 '15 at 20:34

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.