Graphics, Figures & Tablescaption alignment in longtable

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
yaakov
Posts: 7
Joined: Sat Mar 27, 2010 6:18 pm

caption alignment in longtable

Post by yaakov »

hey guys,

following problem: im using longtable and want the caption to be align to the very left, not in the center. i read that the caption-package should do its job also in longtable, but it seems it doesnt work. in the preamble i added the option: justification=RaggedRight

here is my code:

Code: Select all

\documentclass[english,headsepline,headings=normal,bibliography=totocnumbered,version=first,a4paper,numbers=noendperiod]{scrreprt} 
\renewcommand{\rmdefault}{phv}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4} 
\usepackage[tablewithin=none,figurewithin=none,justification=raggedright,singlelinecheck=false]{caption} 
\usepackage[english]{babel} 
\usepackage{color}
\usepackage{longtable}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{color}
\usepackage{longtable}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{textcomp}
\usepackage[automark]{scrpage2}
\usepackage{alltt}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{url}
\usepackage{booktabs,tocbasic,natbib} 
\usepackage{multirow}
\usepackage{array}
\usepackage{units} 
\usepackage{changepage}
\usepackage[colorlinks=true]{hyperref}
\begin{document}
\chapter{TEST}
\section{test page}
this is a test page for various things.
\begin{longtable}{lrlll}
\caption{bla bla bla.} \\
	\toprule 
  Buffer & & Composition  &  & Comments \\  % \multicolumn{1}{l}{Buffer}
	\midrule
\endhead	
	
	\textit{Media} \tabularnewline
	\cline{1-1} \tabularnewline
	2x YT &	31g	& 2x yeast tryptone mix & &	per liter	 \\
	& \\
	TYH -ADD REF. &			 20g & tryptone        & & per liter; pH 7,2 calibrated with KOH \\
			&			 10g & yeast extract   &  & \\
			& 		 11g & HEPES				 		&  & \\
			&			 5g  & NaCl					 	&  & \\
			&			 1g  & MgSO$_{4}$			&  & \\
	&\\
	2x YT-Agar & 15,5g & 2xYT 	  &		 & per 500mL \\
						 & 1\%   & glucose	&	 & w/v	\\
						 & 1.5\% & agar	   	&	 & w/v	\\
	&\\
						 
	\textit{SDS-PAGE \& Western Blot} \\
	\cline{1-1} \\
	SDS electrophoresis buffer &			 25mM & TRIS       &   & \\
														 &			192mM & glycine   &  \\
			                       & 	    0,1\% & sodium dodecyl sulfate		& & w/v \\
	&\\			
	Upper TRIS	& 125mM & TRIS & & pH 6.8 \\
							& 0.4\% & sodium dodecyl sulfate &  & w/v \\
	&\\
	Lower TRIS	& 375mM & TRIS & & pH 8.8 \\
							& 0.4\% & sodium dodecyl sulfate & & w/v \\
	&\\
	5x SDS Sample Buffer &  175mM & TRIS        & & pH 6.8 \\
	- reducing -      &			 50\% & glycerol    &  & v/v \\
		              	& 		 10\% & sodium dodecyl sulfate	&  & w/v \\
			              &			 5\%  & $\beta$$-$ mercaptoethanol 	& & v/v \\
			              &		0.15\%  & bromphenol blue    			&  & w/v \\
	&\\
	5x SDS Sample Buffer &  175mM & TRIS        &  & pH 6.8 \\
	- non-reducing -     &	 50\% & glycerol    &  & v/v \\
		              	& 		 10\% & sodium dodecyl sulfate	&  & w/v \\
			              &			 10mM & iodacetamid	&  & v/v \\
			              &		0.15\%  & bromphenol blue    			&  & w/v \\
	&\\
	Wet Western Blot Buffer &  48mM & TRIS        &  & pH 9.2 \\
										&	 39mM & glycine    &  &  \\
		              	&  20\% & methanol	&  & v/v \\
	&\\
	
  \textit{Agarose Gels} \\
	\cline{1-1} \\
	TAE Buffer			 &			 40mM & TRIS       &   & \\
									 &			  5mM & sodium acetate  & &  \\
			             & 	      5mM & acetic acid		& & w/v \\
			             &			  1mM & Na${_2}$*EDTA*2H${_2}$O &  &  \\
	&\\			
	6x DNA Loading Buffer			 &			 0,25\% & bromphenol blue      & & w/v    \\
									 &	   0,25\% & xylene cyanole   & & w/v  \\
			             & 	     40\% & sucrose		& & w/v \\
	&\\			
	10x Orange G DNA Buffer	 &			 4,42mM & Orange G   & & w/v  \\
								        	 &	       30\% & glycerol   & & w/v  \\
	&\\			
	
  \textit{IMAC Purification} \\
	\cline{1-1} \\
	TBS 400   			 &		  100mM & TRIS       &   & pH 8 \\
									 &			400mM & sodium chloride  & &  \\
	&\\	
	TBS-W     			 &		  100mM & TRIS       &   & pH 8 \\
									 &			400mM & sodium chloride  & &  \\
									 &			 20mM & imidazole  & &  \\
	&\\	
	TBS-W     			 &		  100mM & TRIS       &   & pH 8 \\
									 &			400mM & sodium chloride  & &  \\
									 &			250mM & imidazole  & &  \\
									 &			 10\% & glycerole  & &  \\
	&\\
\label{tab:test}
\end{longtable}
\end{document}
anyone got an idea of how to align that caption to the left?

thanks a lot in advance!

cheers yaakov

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

caption alignment in longtable

Post by gmedina »

Hi,

maybe it has something to do with the \LTcapwidth length defined by the longtable package to control the caption width, but I'm not sure. Anyway, you can use the margin option for the \captionsetup command:

Code: Select all

\documentclass[english,headsepline,headings=normal,bibliography=totocnumbered,version=first,a4paper,numbers=noendperiod]{scrreprt} 
\usepackage[tablewithin=none,figurewithin=none,singlelinecheck=false]{caption} 
\usepackage{longtable,booktabs}

\begin{document}
\chapter{TEST}
\section{test page}
this is a test page for various things.

text text
\begin{longtable}{lrlll}
\captionsetup{margin=-14pt}
\caption{bla bla bla.} \\
   \toprule 
  Buffer & & Composition  &  & Comments \\  % \multicolumn{1}{l}{Buffer}
   \midrule
\endhead   
   \textit{Media} \tabularnewline
   \cline{1-1} \tabularnewline
   2x YT &   31g   & 2x yeast tryptone mix & &   per liter    \\
   & \\
   TYH -ADD REF. &          20g & tryptone        & & per liter; pH 7,2 calibrated with KOH \\
...
\label{tab:test}
\end{longtable}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
yaakov
Posts: 7
Joined: Sat Mar 27, 2010 6:18 pm

Re: caption alignment in longtable

Post by yaakov »

thx for the fast reply!

i noticed a mistake... since my last column 'comments' was too long, caption wasnt positioned as it should. so i took off 'pH 7,2 calibrated with KOH' --> now i get a proper alignment...

but there is a resulting question to it: i then aligned longtable with the option [l] to the left. but the table itself is not as wide as the text.

so how do i set longtable to the textwidht?

thanks!
Post Reply