3

The following MWE sets some boxed texts on the margin:

\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{blindtext}
\begin{document}
\marginline{\tikz[baseline=(n.base)]\node[rounded corners,draw] (n) {200};}
\blindtext
\marginline{\tikz[baseline=(n.base)]\node[rounded corners,draw] (n) {demo};}
\blindtext
\marginline{\tikz[baseline=(n.base)]\node[rounded corners,draw] (n) {$(a,b)*(c,d)$};}
\end{document}

The margin texts are aligned to the left side. However, I would like to have the margin text centered and I'm looking for a solution.

6

You can add \centering manually, redefine \marginline or define a new command:

\documentclass{scrartcl}\show\marginline
\usepackage{tikz}
\usepackage{blindtext}

\newcommand\cmarginline[1]{% or \renewcommand\marginline[1]
  \marginpar[\centering {#1}]{\centering #1}%
}
\begin{document}
\cmarginline{\tikz[baseline=(n.base)]\node[rounded corners,draw] (n) {200};}
\blindtext
\cmarginline{\tikz[baseline=(n.base)]\node[rounded corners,draw] (n) {demo};}
\blindtext
\cmarginline{\tikz[baseline=(n.base)]\node[rounded corners,draw] (n) {$(a,b)*(c,d)$};}
\end{document}

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.