Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to do something like this

\marginnote{
\hspace{\stretch{1}}
\framebox{text}
\hspace{\stretch{1}}
}

i.e., center the marginnote. The problem seems to be that the width is defined to be that of \textwidth, so that the \stretch command assumes a margin width far larger than the actual 106pt. How can I redefine the width for \stretch?

share|improve this question
    
assumes the marginnote package - i guess however it goes the same for \marginpar{}. –  0sh Jan 8 '11 at 21:17
    
Without a minimal compilable example it's hard to test if it works, but I'd try and replace \hspace{\stretch{1}} with \hss (TeX command for horizontal stretch and shrink). –  Hendrik Vogt Jan 8 '11 at 21:27
add comment

2 Answers

Why not simply use \raggedrightmarginnote and \raggedleftmarginnote? See p. 3 of the marginnote documentation for details.

\documentclass{article}

\usepackage{marginnote}
\renewcommand*{\raggedrightmarginnote}{\centering}
% \renewcommand*{\raggedleftmarginnote}{\centering}% for margin notes at the left margin

\usepackage{blindtext}

\begin{document}

Some text.\marginnote{Some text inside a marginnote.} \blindtext

\end{document}
share|improve this answer
add comment
up vote 0 down vote accepted

I found a solution:

\marginnote{\makebox[120pt]{\fcolorbox{light2}{light}{asaddsdd}}}

with other words, you make a box with the correct margin width and the content will then center automatically.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.