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.

mdframed has an option of frametitlealignment, but the manual does not list possible values. I wonder if it accepts values other than left, right and center (apart from derivatives like raggedleft).

Is it possible to place the title in a custom place (e.g. 30% from left)?

If not, how to set padding (margin) for the title? I simply moved the title by

frametitle=\hspace{1em}Title

but the problem is that I use the title in the page header, and do not want this hspace there.

EDIT: MWE for clarification of the problem.

\documentclass{article}

\usepackage{mdframed}
\usepackage{lipsum}
\makeatletter
\mdfdefinestyle{example}{settings={\@mkboth{\mdf@frametitle}{\mdf@frametitle}}}
\makeatother
\pagestyle{headings}
\begin{document}

\begin{mdframed}[style=example,frametitle=\hspace*{0.30\linewidth}Some Title 1]
\lipsum[1]
\end{mdframed}
\end{document}

enter image description here enter image description here

As can be seen, by adding \hspace to the frametitle, not only the frame title shifts, but also the page header will do. I need to customize the position of frame title, but not the page header.

In fact, I cannot alter frametitle, as its value is exactly used in the page header. I need to align the frame title with frametitlealignment.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can use frametitlealignment={\hspace*{0.30\linewidth}} to position the text to 30% the \linewidth:

enter image description here

\documentclass{article}

\usepackage{mdframed}
\usepackage{lipsum}
\makeatletter
\mdfdefinestyle{example}{settings={\@mkboth{\mdf@frametitle}{\mdf@frametitle}}}
\makeatother
\pagestyle{headings}
\begin{document}

\begin{mdframed}[style=example,frametitle=Some Title 1,
frametitlealignment={\hspace*{0.30\linewidth}}]
\lipsum[1]
\end{mdframed}
\end{document}
share|improve this answer
    
As I described, I use the frame title in the page header, I do not need this margin on my page header. If altering the content of frametitle={} it will be exactly displayed on the page header too. –  All Jun 5 '12 at 15:37
    
Can you compose a MWE that shows the problem with this. –  Peter Grill Jun 5 '12 at 15:40
    
I added a MWE to clarify the problem. –  All Jun 5 '12 at 15:54
    
@Ali: Ok, have updated to use frametitlealignment. –  Peter Grill Jun 5 '12 at 16:03
3  
@Ali: Well, don't feel bad, neither did I. I just guessed correctly. –  Peter Grill Jun 5 '12 at 16:16

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.