1

I want to take the caption of the table to right from left. Is it possible? enter image description here

\documentclass[a4paper]{article}
\usepackage{enumitem}
\usepackage{array}
\usepackage{multirow}
\usepackage{ltablex, booktabs}
\renewcommand{\tabularxcolumn}[1]{>{\raggedright\arraybackslash}m{#1}}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1pt}
\setlength\arrayrulewidth{0.3pt}
\usepackage[tableposition=below]{caption}
\newcommand{\myhdashline}{%
\addlinespace
\hdashline
\addlinespace}
\usepackage{subfiles}
\usepackage{caption}
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage{floatpag}
\usepackage{float}
\usepackage{titlesec}
\titleformat{\section}                                     
 {\normalfont\Large\bfseries}
  {\thesection.}{0.5em}{}
\titleformat{\subsection}                                   
   {\normalfont\bfseries}
  {\thesubsection.}{0.5em}{}
  \usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage[margin=1in,headsep=.15in]{geometry}
\pagestyle{fancy}
\fancyhf{}
\chead{\footnotesize Financial Disclosure Index}
\begin{document}

\begin{tabularx}{\textwidth}
{>{\hsize=1.3\hsize}X>{\hsize=0.7\hsize}X}

\textbf{Caption} \\ \midrule \endfirsthead

\textbf{Caption} \\ \midrule \endhead \bottomrule \endfoot

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\textbf{Title} & \\hline

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

TextTextTextTextTextTextText&TextTextTextTextTextTextText\\myhdashline
TextTextTextTextTextTextText & TextTextTextTextTextTextText
\\myhdashline TextTextTextTextTextTextText &
TextTextTextTextTextTextText

\end{tabularx}

\end{document}
13
  • You seem to be mixing longtable notation with your use of tabularx...
    – Werner
    Dec 28, 2018 at 17:50
  • 1
    caption had not to be inside tabularx environment. exception is when you use ltablex package, but this is not evident from your document example.
    – Zarko
    Dec 28, 2018 at 17:50
  • sorry I forget to add packages I used. Yes, I installed ltablex.
    – nebtune
    Dec 28, 2018 at 17:58
  • @nebtune, please edit your question and add missing packages and explain your problem better. is your table with tabularx environment really so long that had to be broken over two or more pages?
    – Zarko
    Dec 28, 2018 at 18:01
  • @ Zarko I tried to add what you suggested. I hope it works. Sorry, I am not so familiar with these.
    – nebtune
    Dec 28, 2018 at 18:39

1 Answer 1

2

You are manually placing the caption within your tabular. If you want it to a) span the whole width and b) be right aligned, you could use a \multicolumn. Alternatively you could simply place a real caption outside the tabular.

\documentclass[a4paper]{article}

\usepackage{array}
\usepackage{multirow}
\usepackage{ltablex, booktabs}
\renewcommand{\tabularxcolumn}[1]{>{\raggedright\arraybackslash}m{#1}}
\usepackage[margin=1in,headsep=.15in]{geometry}

\begin{document}

\begin{tabularx}{\textwidth}
{>{\hsize=1.3\hsize}X>{\hsize=0.7\hsize}X}

\multicolumn{2}{r}{\textbf{Caption}} \\ \midrule \endfirsthead

\textbf{Caption} \\ \midrule \endhead \bottomrule \endfoot

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\textbf{Title} & \\hline

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

TextTextTextTextTextTextText&TextTextTextTextTextTextText\\myhdashline
TextTextTextTextTextTextText & TextTextTextTextTextTextText
\\myhdashline TextTextTextTextTextTextText &
TextTextTextTextTextTextText

\end{tabularx}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .