0

I want to split the whole page into two parts. I am going to use left part as a sidebar.

Code:

\documentclass[11pt]{article}
\usepackage{color}
\usepackage[margin=0cm]{geometry}
\usepackage{graphicx}
\definecolor{cvGray}{rgb}{0.44, 0.52, 0.58}

\begin{document}    
\colorbox{cvGray} {
    \begin{minipage}{0.3\textwidth}       
    \end{minipage}
}
\begin{minipage}{0.7\textwidth}
\end{minipage}  
\end{document}

Output:

enter image description here

Target output:

enter image description here

I generated the Target output with this code:

\documentclass[11pt]{article}
\usepackage{color}
\usepackage[margin=0cm]{geometry}
\definecolor{cvGray}{rgb}{0.44, 0.52, 0.58}

\begin{document}
    \begin{picture}(0,0)
       \put(-20,-850){\color{cvGray}
       \rule{8cm}{81cm}}
    \end{picture}
\end{document}

I could have used the above code but it doesn't seem right way to do things. So how could I achieve the target output by using minipage ?

1

Your boxes do not fit on one line, and you have a word space between them, so they are set one above the other.


parindent\colorbox{cvGray} {fboxsep space
\begin{minipage}{0.3\textwidth}
box content
\end{minipage} space
fboxsep}space
\begin{minipage}{0.7\textwidth}
box content
\end{minipage}


So, you need to remove the word spaces and account for the fboxsep padding added by \colorbox.

Also you need to force the boxes to be full height even when empty.

Something like this, depending a bit how tall you want the split in relation to page head and foot

\documentclass[11pt]{article}
\usepackage{color}
\usepackage[margin=0cm]{geometry}
\usepackage{graphicx}
\definecolor{cvGray}{rgb}{0.44, 0.52, 0.58}

\begin{document}
\vspace*{-\topskip}    
\noindent
\colorbox{cvGray} {%
    \begin{minipage}[t][\dimexpr\textheight-\baselineskip]{\dimexpr0.3\textwidth-2\fboxsep\relax}
a
    \end{minipage}%
}%
\begin{minipage}[t][\dimexpr\textheight-\baselineskip]{0.7\textwidth}
b
\end{minipage}%

\end{document}
12
  • Thanks :) I don't want page head and foot – Ahtisham Jun 13 '20 at 19:18
  • ok add \pagestyle{empty} somewhere then @Ahtisham – David Carlisle Jun 13 '20 at 19:35
  • where somewhere ? can you give hint – Ahtisham Jun 13 '20 at 19:40
  • +1 for getting closer to the answer :) – Ahtisham Jun 13 '20 at 19:40
  • actually more or less anywhere in this example. The line before \begin{document} woudl be a good place – David Carlisle Jun 13 '20 at 19:41

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.