Using Algorithm in Tufte LaTeX is making error in Captions











up vote
1
down vote

favorite












I am using algorithm in Tufte LaTeX



Caption is in the middle, and the horizontal line below it is also missing



documentclass{tufte-book}
usepackage{algorithm}
usepackage[noend]{algpseudocode}
begin{document}

begin{algorithm}captionsetup{font={sc}, labelfont={bf,sc}}
caption{Batch Gradient Descent Algorithm}label{alg:batchgradientdescent}
begin{algorithmic}[1]
INPUT $trainingtext{_}examples, alpha, iter$
Function{GradientDescent}{$X, y, alpha, iter$}
State $theta gets$ Initialized to small random values
For{$i in {1,dots,iter}$}
State $Deltatheta_i gets$ 0 Comment{Initialize each $Deltatheta_i$ to 0}
For{each $(x^i, y^i)$ in $training_examples$}
State $h gets theta_0x_0 dots theta_nx_n$ Comment{Compute the output h}
For{each parameter $theta_i$}
State $Deltatheta_i gets Deltatheta_i + alpha(y^i - h)x_i $
EndFor
EndFor
For{each parameter $theta_i$}
State $theta_i gets theta_i + Deltatheta_i$
EndFor

EndFor
EndFunction
end{algorithmic}
end{algorithm}
end{document}


Can anyone tell what's wrong?










share|improve this question
























  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass{...} and ending with end{document}.
    – samcarter
    Apr 27 at 13:24










  • The code that you provided fails to compile for me. After removing the captionsetup and INPUT lines, it did compile successfully and the caption appeared as expected in the margin note area. Can you describe the results you're getting and what you're trying to achieve?
    – godbyk
    Apr 29 at 3:42















up vote
1
down vote

favorite












I am using algorithm in Tufte LaTeX



Caption is in the middle, and the horizontal line below it is also missing



documentclass{tufte-book}
usepackage{algorithm}
usepackage[noend]{algpseudocode}
begin{document}

begin{algorithm}captionsetup{font={sc}, labelfont={bf,sc}}
caption{Batch Gradient Descent Algorithm}label{alg:batchgradientdescent}
begin{algorithmic}[1]
INPUT $trainingtext{_}examples, alpha, iter$
Function{GradientDescent}{$X, y, alpha, iter$}
State $theta gets$ Initialized to small random values
For{$i in {1,dots,iter}$}
State $Deltatheta_i gets$ 0 Comment{Initialize each $Deltatheta_i$ to 0}
For{each $(x^i, y^i)$ in $training_examples$}
State $h gets theta_0x_0 dots theta_nx_n$ Comment{Compute the output h}
For{each parameter $theta_i$}
State $Deltatheta_i gets Deltatheta_i + alpha(y^i - h)x_i $
EndFor
EndFor
For{each parameter $theta_i$}
State $theta_i gets theta_i + Deltatheta_i$
EndFor

EndFor
EndFunction
end{algorithmic}
end{algorithm}
end{document}


Can anyone tell what's wrong?










share|improve this question
























  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass{...} and ending with end{document}.
    – samcarter
    Apr 27 at 13:24










  • The code that you provided fails to compile for me. After removing the captionsetup and INPUT lines, it did compile successfully and the caption appeared as expected in the margin note area. Can you describe the results you're getting and what you're trying to achieve?
    – godbyk
    Apr 29 at 3:42













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am using algorithm in Tufte LaTeX



Caption is in the middle, and the horizontal line below it is also missing



documentclass{tufte-book}
usepackage{algorithm}
usepackage[noend]{algpseudocode}
begin{document}

begin{algorithm}captionsetup{font={sc}, labelfont={bf,sc}}
caption{Batch Gradient Descent Algorithm}label{alg:batchgradientdescent}
begin{algorithmic}[1]
INPUT $trainingtext{_}examples, alpha, iter$
Function{GradientDescent}{$X, y, alpha, iter$}
State $theta gets$ Initialized to small random values
For{$i in {1,dots,iter}$}
State $Deltatheta_i gets$ 0 Comment{Initialize each $Deltatheta_i$ to 0}
For{each $(x^i, y^i)$ in $training_examples$}
State $h gets theta_0x_0 dots theta_nx_n$ Comment{Compute the output h}
For{each parameter $theta_i$}
State $Deltatheta_i gets Deltatheta_i + alpha(y^i - h)x_i $
EndFor
EndFor
For{each parameter $theta_i$}
State $theta_i gets theta_i + Deltatheta_i$
EndFor

EndFor
EndFunction
end{algorithmic}
end{algorithm}
end{document}


Can anyone tell what's wrong?










share|improve this question















I am using algorithm in Tufte LaTeX



Caption is in the middle, and the horizontal line below it is also missing



documentclass{tufte-book}
usepackage{algorithm}
usepackage[noend]{algpseudocode}
begin{document}

begin{algorithm}captionsetup{font={sc}, labelfont={bf,sc}}
caption{Batch Gradient Descent Algorithm}label{alg:batchgradientdescent}
begin{algorithmic}[1]
INPUT $trainingtext{_}examples, alpha, iter$
Function{GradientDescent}{$X, y, alpha, iter$}
State $theta gets$ Initialized to small random values
For{$i in {1,dots,iter}$}
State $Deltatheta_i gets$ 0 Comment{Initialize each $Deltatheta_i$ to 0}
For{each $(x^i, y^i)$ in $training_examples$}
State $h gets theta_0x_0 dots theta_nx_n$ Comment{Compute the output h}
For{each parameter $theta_i$}
State $Deltatheta_i gets Deltatheta_i + alpha(y^i - h)x_i $
EndFor
EndFor
For{each parameter $theta_i$}
State $theta_i gets theta_i + Deltatheta_i$
EndFor

EndFor
EndFunction
end{algorithmic}
end{algorithm}
end{document}


Can anyone tell what's wrong?







tufte algorithmicx






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 hours ago









Kurt

33.9k846156




33.9k846156










asked Apr 27 at 13:20









Siddharth Kanungo

62




62












  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass{...} and ending with end{document}.
    – samcarter
    Apr 27 at 13:24










  • The code that you provided fails to compile for me. After removing the captionsetup and INPUT lines, it did compile successfully and the caption appeared as expected in the margin note area. Can you describe the results you're getting and what you're trying to achieve?
    – godbyk
    Apr 29 at 3:42


















  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass{...} and ending with end{document}.
    – samcarter
    Apr 27 at 13:24










  • The code that you provided fails to compile for me. After removing the captionsetup and INPUT lines, it did compile successfully and the caption appeared as expected in the margin note area. Can you describe the results you're getting and what you're trying to achieve?
    – godbyk
    Apr 29 at 3:42
















Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass{...} and ending with end{document}.
– samcarter
Apr 27 at 13:24




Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass{...} and ending with end{document}.
– samcarter
Apr 27 at 13:24












The code that you provided fails to compile for me. After removing the captionsetup and INPUT lines, it did compile successfully and the caption appeared as expected in the margin note area. Can you describe the results you're getting and what you're trying to achieve?
– godbyk
Apr 29 at 3:42




The code that you provided fails to compile for me. After removing the captionsetup and INPUT lines, it did compile successfully and the caption appeared as expected in the margin note area. Can you describe the results you're getting and what you're trying to achieve?
– godbyk
Apr 29 at 3:42










1 Answer
1






active

oldest

votes

















up vote
0
down vote













With the packages you are using in you code command Input is not defined. You can define it with



algnewcommandInput{item[textbf{Input:}]}% <=========================


Please see that you need to change your line with INPUT to



Input{$training_examples, alpha, iter$} % <==========================


With the following MWE



documentclass{tufte-book} % tufte-book article

usepackage{algorithm}
usepackage[noend]{algpseudocode}
algnewcommandInput{item[textbf{Input:}]}% <=========================
usepackage{caption} % <================================================


begin{document}
text
captionsetup{font={sc}, labelfont={bf,sc}} % <=========================
begin{algorithm}
caption{Batch Gradient Descent Algorithm}label{alg:batchgradientdescent}
begin{algorithmic}[1]
Input{$training_examples, alpha, iter$} % <==========================
Function{GradientDescent}{$X, y, alpha, iter$}
State $theta gets$ Initialized to small random values
For{$i in {1,dots,iter}$}
State $Deltatheta_i gets$ 0 Comment{Initialize each $Deltatheta_i$ to 0}
For{each $(x^i, y^i)$ in $training_examples$}
State $h gets theta_0x_0 dots theta_nx_n$ Comment{Compute the output h}
For{each parameter $theta_i$}
State $Deltatheta_i gets Deltatheta_i + alpha(y^i - h)x_i $
EndFor
EndFor
For{each parameter $theta_i$}
State $theta_i gets theta_i + Deltatheta_i$
EndFor
EndFor
EndFunction
end{algorithmic}
end{algorithm}
text
end{document}


you get the following result:



enter image description here



Please see that tufte gives you a warning about the usage of caption! See the caption beside the algorithm as designed in tufte ...






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f428857%2fusing-algorithm-in-tufte-latex-is-making-error-in-captions%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    With the packages you are using in you code command Input is not defined. You can define it with



    algnewcommandInput{item[textbf{Input:}]}% <=========================


    Please see that you need to change your line with INPUT to



    Input{$training_examples, alpha, iter$} % <==========================


    With the following MWE



    documentclass{tufte-book} % tufte-book article

    usepackage{algorithm}
    usepackage[noend]{algpseudocode}
    algnewcommandInput{item[textbf{Input:}]}% <=========================
    usepackage{caption} % <================================================


    begin{document}
    text
    captionsetup{font={sc}, labelfont={bf,sc}} % <=========================
    begin{algorithm}
    caption{Batch Gradient Descent Algorithm}label{alg:batchgradientdescent}
    begin{algorithmic}[1]
    Input{$training_examples, alpha, iter$} % <==========================
    Function{GradientDescent}{$X, y, alpha, iter$}
    State $theta gets$ Initialized to small random values
    For{$i in {1,dots,iter}$}
    State $Deltatheta_i gets$ 0 Comment{Initialize each $Deltatheta_i$ to 0}
    For{each $(x^i, y^i)$ in $training_examples$}
    State $h gets theta_0x_0 dots theta_nx_n$ Comment{Compute the output h}
    For{each parameter $theta_i$}
    State $Deltatheta_i gets Deltatheta_i + alpha(y^i - h)x_i $
    EndFor
    EndFor
    For{each parameter $theta_i$}
    State $theta_i gets theta_i + Deltatheta_i$
    EndFor
    EndFor
    EndFunction
    end{algorithmic}
    end{algorithm}
    text
    end{document}


    you get the following result:



    enter image description here



    Please see that tufte gives you a warning about the usage of caption! See the caption beside the algorithm as designed in tufte ...






    share|improve this answer

























      up vote
      0
      down vote













      With the packages you are using in you code command Input is not defined. You can define it with



      algnewcommandInput{item[textbf{Input:}]}% <=========================


      Please see that you need to change your line with INPUT to



      Input{$training_examples, alpha, iter$} % <==========================


      With the following MWE



      documentclass{tufte-book} % tufte-book article

      usepackage{algorithm}
      usepackage[noend]{algpseudocode}
      algnewcommandInput{item[textbf{Input:}]}% <=========================
      usepackage{caption} % <================================================


      begin{document}
      text
      captionsetup{font={sc}, labelfont={bf,sc}} % <=========================
      begin{algorithm}
      caption{Batch Gradient Descent Algorithm}label{alg:batchgradientdescent}
      begin{algorithmic}[1]
      Input{$training_examples, alpha, iter$} % <==========================
      Function{GradientDescent}{$X, y, alpha, iter$}
      State $theta gets$ Initialized to small random values
      For{$i in {1,dots,iter}$}
      State $Deltatheta_i gets$ 0 Comment{Initialize each $Deltatheta_i$ to 0}
      For{each $(x^i, y^i)$ in $training_examples$}
      State $h gets theta_0x_0 dots theta_nx_n$ Comment{Compute the output h}
      For{each parameter $theta_i$}
      State $Deltatheta_i gets Deltatheta_i + alpha(y^i - h)x_i $
      EndFor
      EndFor
      For{each parameter $theta_i$}
      State $theta_i gets theta_i + Deltatheta_i$
      EndFor
      EndFor
      EndFunction
      end{algorithmic}
      end{algorithm}
      text
      end{document}


      you get the following result:



      enter image description here



      Please see that tufte gives you a warning about the usage of caption! See the caption beside the algorithm as designed in tufte ...






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        With the packages you are using in you code command Input is not defined. You can define it with



        algnewcommandInput{item[textbf{Input:}]}% <=========================


        Please see that you need to change your line with INPUT to



        Input{$training_examples, alpha, iter$} % <==========================


        With the following MWE



        documentclass{tufte-book} % tufte-book article

        usepackage{algorithm}
        usepackage[noend]{algpseudocode}
        algnewcommandInput{item[textbf{Input:}]}% <=========================
        usepackage{caption} % <================================================


        begin{document}
        text
        captionsetup{font={sc}, labelfont={bf,sc}} % <=========================
        begin{algorithm}
        caption{Batch Gradient Descent Algorithm}label{alg:batchgradientdescent}
        begin{algorithmic}[1]
        Input{$training_examples, alpha, iter$} % <==========================
        Function{GradientDescent}{$X, y, alpha, iter$}
        State $theta gets$ Initialized to small random values
        For{$i in {1,dots,iter}$}
        State $Deltatheta_i gets$ 0 Comment{Initialize each $Deltatheta_i$ to 0}
        For{each $(x^i, y^i)$ in $training_examples$}
        State $h gets theta_0x_0 dots theta_nx_n$ Comment{Compute the output h}
        For{each parameter $theta_i$}
        State $Deltatheta_i gets Deltatheta_i + alpha(y^i - h)x_i $
        EndFor
        EndFor
        For{each parameter $theta_i$}
        State $theta_i gets theta_i + Deltatheta_i$
        EndFor
        EndFor
        EndFunction
        end{algorithmic}
        end{algorithm}
        text
        end{document}


        you get the following result:



        enter image description here



        Please see that tufte gives you a warning about the usage of caption! See the caption beside the algorithm as designed in tufte ...






        share|improve this answer












        With the packages you are using in you code command Input is not defined. You can define it with



        algnewcommandInput{item[textbf{Input:}]}% <=========================


        Please see that you need to change your line with INPUT to



        Input{$training_examples, alpha, iter$} % <==========================


        With the following MWE



        documentclass{tufte-book} % tufte-book article

        usepackage{algorithm}
        usepackage[noend]{algpseudocode}
        algnewcommandInput{item[textbf{Input:}]}% <=========================
        usepackage{caption} % <================================================


        begin{document}
        text
        captionsetup{font={sc}, labelfont={bf,sc}} % <=========================
        begin{algorithm}
        caption{Batch Gradient Descent Algorithm}label{alg:batchgradientdescent}
        begin{algorithmic}[1]
        Input{$training_examples, alpha, iter$} % <==========================
        Function{GradientDescent}{$X, y, alpha, iter$}
        State $theta gets$ Initialized to small random values
        For{$i in {1,dots,iter}$}
        State $Deltatheta_i gets$ 0 Comment{Initialize each $Deltatheta_i$ to 0}
        For{each $(x^i, y^i)$ in $training_examples$}
        State $h gets theta_0x_0 dots theta_nx_n$ Comment{Compute the output h}
        For{each parameter $theta_i$}
        State $Deltatheta_i gets Deltatheta_i + alpha(y^i - h)x_i $
        EndFor
        EndFor
        For{each parameter $theta_i$}
        State $theta_i gets theta_i + Deltatheta_i$
        EndFor
        EndFor
        EndFunction
        end{algorithmic}
        end{algorithm}
        text
        end{document}


        you get the following result:



        enter image description here



        Please see that tufte gives you a warning about the usage of caption! See the caption beside the algorithm as designed in tufte ...







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 12 hours ago









        Kurt

        33.9k846156




        33.9k846156






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f428857%2fusing-algorithm-in-tufte-latex-is-making-error-in-captions%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks