2

Ok, I'm totally frustrated now. I want to place some vertical text right to the main body text. I managed to rotate the text, but the main body text only starts after the vertical text's end.

Currently, it looks like this:

enter image description here

At the end it should like this

enter image description here

Does anyone have some ideas?

  • 2
    Welcome to TeX SX! Could you post what you've tried? – Bernard May 27 at 17:39
  • @Bernard yes of course: I tried to add a table, but I couldn't get the syntax right as there is only one row. I also tried using wrapfigure, but it obvoiusly only works with figures and tables. Oh, just writing this comment I figured out to use a table with single cell to do this and it works – dasch May 27 at 18:08
4

I would like to propose the following approach that introduces the \WriteOnMargin command based partially on TikZ.

Update (for twoside option)

If even and odd pages play role (e.g., for twoside option), one can specify the settings for even/odd pages by \ifodd test to obtain the following output.

enter image description here

The complete code for the example above follows.

\documentclass[twoside]{article}

\usepackage{tikz}

\def\WriteOnMargin#1{%
    %
    % page parity test
    %-----------------
    \ifodd\thepage
        %
        % odd-page setup
        %---------------
        \def\EOwhere{above right}
        \def\EOxshift{1em}
        \relax
    \else
        %
        % even-page setup
        %----------------
        \def\EOwhere{below right}
        \def\EOxshift{9em}
        \relax
    \fi
    %
    % apply settings and typeset the text
    %------------------------------------
    \marginpar{%
        \tikz[overlay]
        \node[%
            cyan,
            \EOwhere,
            xshift=\EOxshift,
            rotate=-90,
            font=\Huge\sffamily] {#1};
    }%
}



\begin{document}
\WriteOnMargin{abcd}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean vel massa quis mauris 
vehicula lacinia. Duis risus. Sed elit dui, pellentesque a, faucibus vel, interdum nec, 
diam. Nulla est. Maecenas aliquet accumsan leo. Mauris metus. Cum sociis natoque 
penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum fermentum 
tortor id mi. Fusce aliquam vestibulum ipsum. Mauris dictum facilisis augue. Pellentesque 
sapien. Pellentesque arcu. In dapibus augue non sapien. Nulla non arcu lacinia neque 
faucibus fringilla.
\newpage

\WriteOnMargin{xyz}
Curabitur ligula sapien, pulvinar a vestibulum quis, facilisis vel sapien. Duis aute 
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla 
pariatur. Integer in sapien. Nulla pulvinar eleifend sem. Nullam lectus justo, vulputate 
eget mollis sed, tempor sed magna. Aliquam erat volutpat. Neque porro quisquam est, qui 
dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius 
modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Maecenas 
sollicitudin. Nullam dapibus fermentum ipsum. Aliquam id dolor. Nulla non arcu lacinia 
neque faucibus fringilla. Integer imperdiet lectus quis justo. Class aptent taciti 
sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Aenean id metus 
id velit ullamcorper pulvinar. Nullam sapien sem, ornare ac, nonummy non, lobortis a 
enim.
\end{document}

 

Original post (without twoside option)

enter image description here

\documentclass{article}

\usepackage{tikz}

\def\WriteOnMargin#1{%
    \marginpar{%
        \tikz[overlay]
        \node[%
            cyan,
            above right,
            xshift=1em,
            rotate=-90,
            font=\Huge\sffamily] {#1};
    }%
}

\begin{document}
\WriteOnMargin{Some text}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean vel massa quis mauris 
vehicula lacinia. Duis risus. Sed elit dui, pellentesque a, faucibus vel, interdum nec, 
diam. Nulla est. Maecenas aliquet accumsan leo. Mauris metus. Cum sociis natoque 
penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum fermentum 
tortor id mi. Fusce aliquam vestibulum ipsum. Mauris dictum facilisis augue. Pellentesque 
sapien. Pellentesque arcu. In dapibus augue non sapien. Nulla non arcu lacinia neque 
faucibus fringilla.

Curabitur ligula sapien, pulvinar a vestibulum quis, facilisis vel sapien. Duis aute 
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla 
pariatur. Integer in sapien. Nulla pulvinar eleifend sem. Nullam lectus justo, vulputate 
eget mollis sed, tempor sed magna. Aliquam erat volutpat. Neque porro quisquam est, qui 
dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius 
modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Maecenas 
sollicitudin. Nullam dapibus fermentum ipsum. Aliquam id dolor. Nulla non arcu lacinia 
neque faucibus fringilla. Integer imperdiet lectus quis justo. Class aptent taciti 
sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Aenean id metus 
id velit ullamcorper pulvinar. Nullam sapien sem, ornare ac, nonummy non, lobortis a 
enim.
\end{document}
  • Thank you, that's perfect because it works fine on double pages too, which I haven't thought of yet. But is there a way to rotate it by 90 or -90 degree, depending on wether the page is a left or right one? – dasch May 27 at 20:23
3

A simple solution with the \InsertBoxR command from the plain TeX macros package insbox. It takes two mandatory arguments: the number of unshortened lines in the paragraph before the box insertion, and the content of the box, and an optional (last) argument: the number of supplementary shorter lines in case TeX computes erroneously the number of necessary shorter lines.

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{adjustbox, rotating}%

\input{insbox}

\makeatletter
\@InsertBoxMargin =15pt
\makeatother

\begin{document}

\sffamily
\InsertBoxR{-1}{\turnbox{-90}{\adjustbox{scale=4}{Vertical text}}}[16]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mau-
ris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec
vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus
et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus
sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit
amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra
ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi
dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper
nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend,
sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.

\lipsum[2]

\end{document} 

enter image description here

  • That's nice and clean indeed, thank you :) – dasch May 27 at 20:18
0

The solution is to use a combination of wraptable and the \hfill on the right position

\begin{wraptable}{r}{0.5cm}
\hfill\begin{tabular}{l}
\begin{turn}{270}
\begingroup{}
\Huge{Vertical Text}
\endgroup{}
\end{turn}
\end{tabular}
\end{wraptable} 
  • 1
    The vertical text should not be in the margin? – Bernard May 27 at 18: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.